Question






write inputs and outputs

declare variables
promt user



b. Modify the program written for Exercise 9a to determine wener e eReTeO evenly divisible by a user-specified value, with no
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The solution to the above question is given below with screenshot of output.

=====================================================

I kept the logic simple and i have tested all outputs.

I Have added comments in program so that it can be easily

understood.

If there is anything else do let me know in comments.

=====================================================

============ CODE TO COPY ===============================

main.cpp

#include <iostream>
using namespace std;

int main()
{
  // Variable for storing grades
  string  grade1 , grade2 ;

  // Variable for storing credits
  int     credit1, credit2;

  // Variable for storing GPA
  double  GPA = 0;

  cout << "Enter Grade For Course 1 : ";
  cin  >> grade1;

  cout << "Enter Credit For Course 1 : ";
  cin  >> credit1;
 
  cout << endl;

  cout << "Enter Grade For Course 2 : ";
  cin  >> grade2;

  cout << "Enter Credit For Course 2 : ";
  cin  >> credit2;

  // GPA FOR COURSE 1
  if ( grade1 == "A" )
    GPA = GPA + 4 * credit1;
  else if ( grade1 == "B")
    GPA = GPA + 3 * credit1;
  else if ( grade1 == "C")
    GPA = GPA + 2 * credit1;
  else if ( grade1 == "D")
    GPA = GPA + 1 * credit1;
  else
    GPA = GPA + 0 * credit1;

  // GPA FOR COURSE 2
  if ( grade2 == "A" )
    GPA = GPA + 4 * credit2;
  else if ( grade2 == "B")
    GPA = GPA + 3 * credit2;
  else if ( grade2 == "C")
    GPA = GPA + 2 * credit2;
  else if ( grade2 == "D")
    GPA = GPA + 1 * credit2;
  else
    GPA = GPA + 0 * credit2;

  cout << endl;

  // Average 
  GPA = GPA /  2 ;

  if ( GPA < 2.0 )
    cout << "Your GPA is Less Than 2.0 : " << GPA << endl;
  else if ( GPA > 3.5 )
    cout << "Your GPA is Good  : " << GPA << endl;
  else
    cout << "Your GPA is  : " << GPA << endl;
  
  return 0;

}

=====================================================

Output :

2 :/main Enter Grade For Course 1 : B Enter Credit For Course 1 : 2 Enter Grade For Course 2 : A Enter Credit For Course 2 :

Add a comment
Know the answer?
Add Answer to:
write inputs and outputs declare variables promt user b. Modify the program written for Exercise 9a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b):...

    Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b): Write a program that gives remainder without using modulus operator and loops. The first number entered will be dividend and second number entered will be divisor. Sample input: 15 6 Sample output: Remainder is 3 In a right triangle, the square of the length of one side is equal to the sum of the squares of the length of the other two sides. Write...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • Do not use pointer variables, pointer arithmetic or operater new ITCS-2530    Project                        Write an...

    Do not use pointer variables, pointer arithmetic or operater new ITCS-2530    Project                        Write an interactive program that performs fractional calculations. You need define a class CFrac for a fractional number according to the UML diagram below: CFrac - numerator : int - denominator : int - simplify () : void + CFrac (int = 0, int = 1) + ~CFrac() + add (const CFrac&) const : CFrac + subtract (const CFrac&) const : CFrac + multiply (const CFrac&)...

  • Exercise #1: Write a C program that contains the following steps (make sure all variables are...

    Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. Commenting out the existing coding, write the code to divide a...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT