Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. //Anna Cowsar
  2. //CS 1428 Fall 2015 Project #3
  3. //Last updated:10/11/2015
  4.  
  5. #include <iostream>
  6. #include <iomanip>
  7. #include <fstream>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. //declaring variables
  14. string name, address, ssn, telephone, Course;
  15. int age, years;
  16. double weight1 = .1; //different test weights
  17. double weight2 = .15;
  18. double weight3 = .15;
  19. double weight4 = .2;
  20. double finalweight = .4;
  21. char A_SCORE = 65; //variables for determining the letter grade
  22. char B_SCORE = 66;
  23. char C_SCORE = 67;
  24. char D_SCORE = 68;
  25. char F_SCORE = 70;
  26. int numStudents;
  27. int numTests = 5;
  28. int numCourses = 3;
  29. //variables for the test grades
  30. double Test1, Test2, Test3, Test4, FinalExam, LetterGrade;
  31.  
  32. //opening an input file
  33. ifstream fin;
  34. fin.open ("Project3_A04367115_Input.txt");
  35.  
  36. //creating an output file and opening it
  37. ofstream fout;
  38. fout.open ("Project3_A04367115_Output.txt");
  39.  
  40. //heading of the output file
  41. cout << "Enter the number of students you wish to see information from: ";
  42. cin >> numStudents;
  43. for (int j = 0; j < numStudents; ++j)
  44. {fout << setw(48) << "Student Grade Sheet \n";
  45. fout << "\t Department of Computer Science, Texas State University, San Marcos" << endl;
  46.  
  47. //reading from the input and printing to the output
  48. fout << right << setw(35) << "Name of Student: ";
  49. getline(fin, name);
  50. fout << left << "\t" << name << endl;
  51.  
  52. fout << right << setw(35) << "Age: ";
  53. fin >> age;
  54. fin.ignore();
  55. fout << left << "\t" << age << endl;
  56.  
  57. fout << right << setw(35) << "Address: ";
  58. getline(fin, address);
  59. fout << left << "\t" << address << endl;
  60.  
  61. fout << right << setw(35) << "Number of years at Texas State: ";
  62. fin >> years;
  63. fin.ignore();
  64. fout << left << "\t" << years << endl;
  65.  
  66. fout << right<< setw(35) << "Telephone Number: ";
  67. getline(fin, telephone);
  68. fout << left << "\t" << telephone << endl;
  69.  
  70. fout << right << setw(35) << "Student Soc. Security #: ";
  71. getline(fin, ssn);
  72. fout << left << "\t" << ssn << endl;
  73.  
  74.  
  75.  
  76. for (int j = 1; j < numCourses; ++j)
  77. { fout << right << setw(35) << "Course Number: ";
  78. fin >> Course;
  79. fin.ignore();
  80. fout << left << "\t" << Course << endl;
  81.  
  82. for (int k=1; k < numTests; ++k)
  83. {
  84. fout << right << setw(32) << "Test #" << k << ": ";
  85. fin >> Test1;
  86. fin.ignore();
  87. fout << right << "\t" << showpoint << fixed << setprecision(1) << Test1 << endl;
  88. }
  89. fout << right << setw(35) << "Final Exam: ";
  90. fin >> FinalExam;
  91. fout << left << "\t" << fixed << setprecision(1) << FinalExam << endl;
  92. fin.ignore();
  93.  
  94.  
  95. //calculating the student's final grade
  96. double FinalGrade = (Test1 * weight1) + (Test2 * weight2) + (Test3 * weight3) + (Test4 * weight4)
  97. + (FinalExam * finalweight);
  98. fout << right << setw(35) << "Numerical Grade: " << left << "\t" << FinalGrade << endl;
  99.  
  100. //if statements for determining the student's letter grade
  101. fout << right << setw(35) << "Letter Grade: ";
  102. if (FinalGrade >= A_SCORE)
  103. {
  104. fout << "\t" << A_SCORE << endl;
  105. }
  106.  
  107. else if (FinalGrade >= B_SCORE)
  108. {
  109. fout << "\t" << B_SCORE << endl;
  110. }
  111.  
  112. else if (FinalGrade >= C_SCORE)
  113. {
  114. fout << "\t" << C_SCORE << endl;
  115. }
  116.  
  117. else if (FinalGrade >= D_SCORE)
  118. {
  119. fout << "\t" << D_SCORE << endl;
  120. }
  121.  
  122. else
  123. {
  124. fout << "\t" << F_SCORE << endl;
  125. }
  126. }}
  127. fout << "\t Course Instructor is Kelly Princeton, professor, Department of Computer Science Texas State University, San Marcos, TX 78666";
  128.  
  129. //closing files
  130. fin.close();
  131. fout.close();
  132.  
  133. return 0;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement