Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10. string a;
  11. string b;
  12. char ch;
  13. int grade; // I put this here because my the switch in the parathensis is called grade and unless i declare it as something it won't compile properly and run.
  14.  
  15. double c;
  16. double d;
  17. double e;
  18. int Average;
  19. int sum;
  20.  
  21. cout << "Enter the first name " << endl;
  22. cin >> a;
  23. cout << "Enter the last name" << endl;
  24. cin >> b;
  25. cout << "Enter the three test scores" << endl;
  26. cin >> c >> d >> e;
  27.  
  28. sum = c+d+e;
  29. Average = sum/3;
  30. grade = Average;
  31.  
  32.  
  33. cout << setfill('-');
  34. cout << "First" << setw(9);
  35. cout << "Last" << setw(25);
  36. cout << "Test 1" << setw(8);
  37. cout << "Test 2" << setw(8);
  38. cout << "Test3" << setw(10);
  39. cout << "Average" << setw(8);
  40. cout << "Grade" << endl;
  41. cout << a << setw(11);
  42. cout << b << setw(24);
  43. cout << c << setw(8);
  44. cout << d << setw(8);
  45. cout << e << setw(10);
  46. cout << Average << setw(8);
  47. switch (grade)
  48. {
  49. case 0:
  50. case 1:
  51. case 2:
  52. case 3:
  53. cout << "F";
  54. break;
  55. case 4:
  56. cout << "D";
  57. break;
  58. case 5:
  59. cout << "C";
  60. break;
  61. case 6:
  62. cout << "C+";
  63. break;
  64. case 7:
  65. case 8:
  66. cout << "B";
  67. break;
  68. case 9:
  69. case 10:
  70. cout << "A";
  71. break;
  72. default:
  73. cout << "Invalid Entry";
  74. }
  75. cout << endl << endl;
  76.  
  77. ofstream myfile;
  78. myfile.open("example.txt");
  79. myfile << a << b << c << d << e << grade << '\n';
  80. myfile.close();
  81.  
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement