wheelsmanx

CPS 171 Machine Problem 2

Oct 17th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4.  
  5. #include "stdafx.h"
  6. #include <iostream>
  7. #include <string>
  8. #include <fstream>
  9. // an example of a prime number is a number that is only divisible by its self and 1
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. ifstream fin;
  16. string schoolcode;
  17. float gpa;
  18. float mathscore;
  19. float verbalscore;
  20. string isalum;
  21. float usersumsat;
  22. float count = 0;
  23. float countnumber = 0;
  24. float countnumber2 = 0;
  25.  
  26.  
  27. fin.open("C:\\temp\\mp3accept.txt");
  28.  
  29. while (!fin.eof())
  30. {
  31. fin >> schoolcode >> gpa >> mathscore >> verbalscore >> isalum;
  32.  
  33. cout << "Applicant Number: " << count << endl;
  34. count = count + 1;
  35. cout << "School: " << schoolcode << " GPA: " << gpa << " Math: " << mathscore << " Verbal: " << verbalscore << " Alumnus: " << isalum << endl;
  36.  
  37.  
  38.  
  39. if (schoolcode == "M" && mathscore >= 500 && verbalscore >= 500) {
  40. cout << "You Applied To Music!" << endl;
  41. cout << "You Were Accepted!" << endl;
  42. countnumber = countnumber + 1;
  43. }
  44. else if (schoolcode == "L" && isalum == "Y") {
  45. if (gpa >= 3) {
  46. usersumsat = verbalscore + mathscore;
  47. if (usersumsat >= 1000)
  48. {
  49. cout << "You Applied to Libral Arts" << endl << "You Were Accepted To Libral Arts" << endl;
  50. countnumber2 = countnumber2 + 1;
  51. }
  52. else {
  53. cout << "You Applied to Libral Arts" << endl << "You failed because of your SAT" << endl;
  54. }
  55. }
  56. else {
  57. cout << "You Applied to Libral Arts" << endl << "You failed because of your GPA" << endl;
  58. }
  59. }
  60. else if (schoolcode == "L" && isalum == "N") {
  61. usersumsat = mathscore + verbalscore;
  62. if (gpa >= 3.5)
  63. {
  64. if (usersumsat >= 1200)
  65. {
  66. cout << "You Applied to Libral Arts" << endl << "You Were Accepted!" << endl;
  67. countnumber2 = countnumber2 + 1;
  68. }
  69. else
  70. {
  71. cout << "You Applied to Libral Arts" << endl << "You failed because of your SAT" << endl;
  72. }
  73.  
  74.  
  75. }
  76. else {
  77. cout << "You Applied to Libral Arts" << endl << "You Failed because of your GPA." << endl;
  78. }
  79. }
  80. else {
  81. cout << "You Applied to Libral Arts" << endl << "You failed because of your SAT" << endl;
  82.  
  83. }
  84. cout << "============================================" << endl;
  85.  
  86.  
  87. }
  88. cout << "There were " << count << " applicants in the file." << endl;
  89. cout << "There were " << countnumber << " acceptances to music." << endl;
  90. cout << "There were " << countnumber2 << " acceptances to libral arts." << endl;
  91. fin.close();
  92. // this is going to pause the program
  93. system("pause");
  94. // this is going to close the program out
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment