Question

This is in C++.

You will write a program that will prompt the user to enter a grade out of 100 and then show them what the equivalent grade p

Example:

Enter percentage grades to convert to grade points. Enter -1 to quit. Percentage grade: chicken * Invalid input. Please try

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

#include<iostream>
#include<iomanip>
using namespace std;
double GradePoints(double *);
int main()
{
   double percentage_grade=0,grade_point;
   cout << fixed << setprecision(1);
   cout << "Enter percentage grades to convert to grade points. Enter '-1' to quit.\n\n";
   while(true)
   {
       cout << "Percentage grade: ";
       cin >> percentage_grade;
       if (percentage_grade == -1)
           break;
       while (cin.fail())
       {
           cout << "* Invalid input. Please try again ad enter a numeric value" << endl;;
           cin.clear();
           cin.ignore(INT_MAX, '\n');
           cin >> percentage_grade;
       }
       try
       {
           grade_point = GradePoints(&percentage_grade);
           cout <<endl <<percentage_grade << "% is " << grade_point << " grade points." << endl;
           cout << endl;
       }
       catch (const char* msg)
       {
           cerr << endl<<msg << endl;
           cout << endl;
       }
   }
   cout << "\nGood bye!" << endl<<endl;
  
   return 1;
}
double GradePoints(double *per)
{
   if (*per < 0 || *per >100)
   {
       throw "An exception occurred: Grade must be between 0.0000 and 100.0000";
   }
   *per = round(*per);
   if (*per >= 90)
       return 5.0;
   else if (*per >= 85 && *per <= 89)
       return 4.5;
   else if (*per >= 80 && *per <= 84)
       return 4.0;
   else if (*per >= 75 && *per <= 79)
       return 3.5;
   else if (*per >= 70 && *per <= 74)
       return 3.0;
   else if (*per >= 65 && *per <= 69)
       return 2.5;
   else if (*per >= 60 && *per <= 64)
       return 2.0;
   else if (*per >= 55 && *per <= 59)
       return 1.5;
   else if (*per >= 50 && *per <= 54)
       return 1.0;
   return 0;
}

output

I D:\Chegg\C++\Student grade point from percentage grade\Debug\Student grade point from percentage grade.exe Enter percentage

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
This is in C++. Example: You will write a program that will prompt the user to...
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
  • Write a C++ program that will provide a user with a grade range if they enter...

    Write a C++ program that will provide a user with a grade range if they enter a letter grade. Your program should contain one function. Your function will accept one argument of type char and will not return anything (the return type will be void), but rather print statements to the console. Your main function will contain code to prompt the user to enter a letter grade. It will pass the letter grade entered by the user to your function....

  • You are to write a program IN C++ that asks the user to enter an item's...

    You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...

  • Write a C++ program that computes student grades for an assignment as a percentage given each...

    Write a C++ program that computes student grades for an assignment as a percentage given each student's score and the total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to...

  • Write a program that computes the average of a set of grades. The user is prompted...

    Write a program that computes the average of a set of grades. The user is prompted the following: 1-Number of grades to be entered. 2-The value of the minimum grade. 3-The value of the maximum grade. Make sure to write input validation for the following: 1-The number of grades cannot be negative! In case it is 0, it means that user has no grades to enter. 2-Each entered grade should be a valid grade between the minimum and maximum values...

  • C++ Grades . Write a program that uses enum types to assign letter grades that can...

    C++ Grades . Write a program that uses enum types to assign letter grades that can be automatically converted to numerical grades. For this assignment, you'll create an enum type with the values F, D, C, B, and A, so the letter grades are associated with ordinal values 0, 1, 2, 3, and 4, respectively (which coincide with the quality points for that grade). Write a method assignCourseGrade(double grade) which takes a real number representing the grade for the class,...

  • Plz help!! The programming language is C and could you write comments as well? Problem 2....

    Plz help!! The programming language is C and could you write comments as well? Problem 2. Calculate Grades (35 points) Arrays can be used for any data type, such as int and char. But they can also be used for complex data types like structs. Structs can be simple, containing simple data types, but they can also contain more complex data types, such as another struct. So you could have a struct inside of a struct. This problem deals with...

  • Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment...

    Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • c++ please (1) Write a program that prompts the user to enter an integer value N...

    c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...

  • Write a console-based program ( C # ) that asks a user to enter a number...

    Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...

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