SHARE
TWEET

Untitled

a guest Jun 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //============================================================================
  2. // Name        : lab05.cpp
  3. // Author      : buitches
  4. // Version     :
  5. // Copyright   : Your copyright notice
  6. // Description : Hello World in C++, Ansi-style
  7. //============================================================================
  8.  
  9. #include <iostream>
  10. #include <cmath>
  11. using namespace std;
  12.  
  13. int main() {
  14.  
  15.     // deeee-finin' wariables
  16.     char letterGrade;
  17.     int point, credits;
  18.  
  19.     do  {
  20.         credits = 0;
  21.  
  22.         cout << "Enter number of credits (1 through 8): ";
  23.         cin >> credits;
  24.  
  25.             while (credits <= 0 || credits >= 9)    {
  26.                 cout << "Invalid number of credits must be 1 or 8 or infinity" << endl;
  27.                 cout << "Enter number of credits (1 through 8): ";
  28.                 cin >> credits;                     }
  29.  
  30.  
  31.         cout << "Enter a letter grade (A, B, C, D, or F): ";
  32.         cin >> letterGrade;
  33.         letterGrade = tolower(letterGrade);
  34.  
  35.             while (letterGrade != 'a' && letterGrade != 'b' && letterGrade != 'c')  {
  36.                 cout << "Invalid letter grade! must be a,b,c,d,f uppercase or lowers" << endl;
  37.                 cout << "Enter a letter grade (A, B, C, D, or F): ";
  38.                 cin >> letterGrade;
  39.                 letterGrade = tolower(letterGrade);                                 }
  40.  
  41.         switch(letterGrade) {
  42.             case 'a':
  43.                 point = 4;
  44.                 break;
  45.             case 'b':
  46.                 point = 3;
  47.                 break;
  48.             case 'c':
  49.                 point = 2;
  50.                 break;
  51.             case 'd':
  52.                 point = 1;
  53.                 break;
  54.             case 'f':
  55.                 point = 0;
  56.                 break;
  57.             default:
  58.                 point = -1;
  59.                 break;
  60.         }
  61.  
  62.         cout << "Points for letter grade " << letterGrade << " is " << point << endl;
  63.         cout << "Number of credits for the course is " << credits << endl;
  64.         cout << "Number of weighted points for the course is " << (credits * point) << endl;
  65.         cout << "------------------------------------------------" << endl;
  66.  
  67.     } while (true);
  68.     return 0;
  69. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top