Advertisement
Guest User

Machine Code Problem 2

a guest
Oct 25th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include<iostream>
  3. #include<cmath>
  4. #include<string>
  5. #include<fstream>
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11.     ifstream fileInput;
  12.  
  13.     fileInput.open("E:\\docs\\C++\\mp3accept.txt");
  14.  
  15.     int applicantNumber = 0;
  16.     char schoolCode;
  17.     float gpa;
  18.     int mathScore;
  19.     int verbalScore;
  20.     char Alum;
  21.  
  22.     int musicLimit = 0;
  23.     int libartsLimit = 0;
  24.     int totalSat;
  25.  
  26.     fileInput >> schoolCode >> gpa >> mathScore >> verbalScore >> Alum;
  27.     while (!fileInput.eof())
  28.     {
  29.         applicantNumber++;
  30.  
  31.         cout << "Applicant #: " << applicantNumber << endl;
  32.         cout << schoolCode << " " << gpa << " ";
  33.         cout << mathScore << " " << verbalScore << " ";
  34.         cout << Alum << endl;
  35.         cout << endl;
  36.  
  37.         totalSat = mathScore + verbalScore;
  38.  
  39.         if (schoolCode == 'M')
  40.             if (musicLimit == 3)
  41.                 cout << "Music Student Quota Met.";
  42.             else if (mathScore >= 500 && verbalScore >= 500)
  43.             {
  44.                 cout << "Qualified for admissions.";
  45.                 musicLimit++;
  46.             }
  47.             else if (mathScore < 500 || verbalScore < 500)
  48.                 cout << "Admission denied: Sat requirement not met.";
  49.             else
  50.                 cout << "Invalid SAT.";
  51.  
  52.         else if (schoolCode == 'L')
  53.             if (libartsLimit == 5)
  54.                 cout << "Liberal Arts Student Quota Met.";
  55.             else if (Alum == 'Y')
  56.                 if (gpa >= 3.0 && totalSat >= 1000)
  57.                 {
  58.                     cout << "Qualified for admission.";
  59.                     libartsLimit++;
  60.                 }
  61.                 else if (gpa < 3.0 || totalSat < 1000)
  62.                     cout << "Admission denied: Sat or GPA requirements not met.";
  63.                 else
  64.                     cout << "Invalid SAT or GPA.";
  65.             else if (Alum == 'N')
  66.                 if (gpa >= 3.5 && totalSat >= 1200)
  67.                 {
  68.                     cout << "Qualified for admission.";
  69.                     libartsLimit++;
  70.                 }
  71.                 else if (gpa < 3.5 || totalSat < 1200)
  72.                     cout << "Admission denied: Sat or GPA requirements not met.";
  73.                 else
  74.                     cout << "Invalid SAT or GPA.";
  75.             else
  76.                 cout << "Incorrect alumni code.";
  77.  
  78.         else
  79.             cout << "Incorrect school code";
  80.  
  81.         cout << "\n------------------\n" << endl;
  82.  
  83.         fileInput >> schoolCode >> gpa >> mathScore >> verbalScore >> Alum;
  84.     }
  85.     fileInput.close();
  86.  
  87.     cout << "There were " << applicantNumber << " applicants in the file.\n";
  88.     cout << "There were " << libartsLimit << " acceptances to Liberal Arts.\n";
  89.     cout << "There were " << musicLimit << " acceptances to Music.\n";
  90.  
  91.     system("pause");
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement