Question

In: Computer Science

Many prestigious universities have a system called a “Legacy Preference System” which is used to decide...

Many prestigious universities have a system called a “Legacy Preference System” which is used to decide which applicants should be accepted to the university. If an applicant’s parent is an alumnus of the university, the applicant will be admitted with lower GPA and SAT scores than if the parent is not an alumnus. (There is currently a lot of discussion about the fairness of this system, but universities get a lot of money from their alumni so they are unwilling to change it!!)

Your assignment for MP2 is to implement a computerized system like this for a very small prestigious university. The university has two schools, Liberal Arts and Music, each with their own criteria for accepting students. Your program must read in certain information about an applicant and print a message saying whether the applicant should be accepted or not.

The criteria for acceptance are:

Liberal Arts

  1. No more than 5 people can be accepted.
  2. If a parent is an alumnus, the GPA must be at least 3.0, but if no parents are alumni the GPA must be at least 3.5.
  3. If a parent is an alumnus, the combined SAT score must be at least 1000, but if no parents are alumni the SAT must be at least 1200.

Music – no preferences for alumni here.

  1. No more than 3 people can be accepted.
  2. Math and verbal SAT’s must be at least 500 each.

Your program must accept as input the school the student is applying to (L or M), their high school grade point average, their math SAT score, their verbal SAT score and whether or not either parent is an alumnus (Y or N). The program must process several applicants, echoing the data for each applicant and printing a message indicating if the student was accepted to the school they were applying to. If they were not accepted, the message should indicate why. This message only has to indicate one reason for failure in cases of multiple disqualifications. Acceptances are to be made in the order received so that if a school is full, a later applicant cannot be accepted even if they happen to have better qualifications than an earlier one. You do NOT have to check for bad data coming from the file – assume that it is in the required format and has appropriate values.

The data file is arranged with the information for each applicant on a separate line. Your program must process the data until the end of file is reached, at which time the program must print out the total number of applicants and the number of acceptances to each school. The data file should be created by you. Create the file and store it in the same project folder as your program. Please turn in a hard copy of this file along with your program and output.

SUGGESTION You should design, compile, run and debug your program in stages. You might start by testing if your program can just read and echo the data file. After this is working accurately move on to identifying the school the person is applying to, then continue to add more of the details. Remember to use good style with consistent indentation, plenty of comments, good variable names etc. and don't forget to echo the data as it is read. The output must be clear and readable with appropriate string constants and spacing. Here is an example of the input data file:

L 4.0 600 650 N
M 3.9 610 520 N
L 3.8 590 600 N

Sample output from the first few lines of the example data file follows:

Acceptance to College by (your name)

Applicant #: 1
School = L GPA = 4.0 math = 600 verbal = 650 alumnus = N
Applying to Liberal Arts
Accepted to Liberal Arts!!!
*******************************
Applicant #: 2
School = M GPA = 3.9 math = 610 verbal = 520 alumnus = N
Applying to Music
Accepted to Music!!
*******************************
Applicant #: 3
School = L GPA = 3.8 math = 590 verbal = 600 alumnus = N
Applying to Liberal Arts
Rejected - SAT is too low
*******************************

There were xx applicants in the file
There were xx acceptances to Liberal Arts
There were xx acceptances to Music
Press any key to continue

Use the following input file for your program, notice there is exactly 14 applicants, make sure you display the counts at the end of your output as in the sample above.


mp2accept.txt

L 4.0 600 650 N
M 3.9 610 520 N
L 3.8 590 600 N
L 3.0 600 600 Y
L 3.4 600 600 N
L 3.0 500 490 Y
L 2.9 500 500 Y
M 3.5 500 490 Y
M 3.9 490 600 Y
L 3.5 700 500 N
L 3.1 600 400 Y
L 3.0 490 510 Y
L 4.0 800 800 Y
M 3.2 500 500 N

here is my solution;(i don't know where I am wrong, I couldn't open up the mp2accept file)

#include <iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;


int main()
{

   //prompt the user for input
   int x;
   ifstream inputFileX;
   inputFileX.open("Cis161:\\assignment2\\mp2accept.txt");// this fstream is to read the data from the file
   getline(inputFileX, line);
   string mp2accept,line;
   if (inputFileX.good() == false) {
       cout << "Unable to open the file named " << mp2accept;
       exit(1);
   }
   while (true) {
       getline(inputFileX, line);
       if (inputFileX.eof()) break;
       FILE OUTPUT
           cout << line << endl;
   //prompt the user for input
  
   char school; // character variable for school and alumunus
   bool LiberalArts = false, Music = true;
   int Math, Verbal; // Integer variable for SAT score
   int SAT;
   float GPA; // float variable for GPA
   char Alumunus;// character variable for alumunus

   // is the student accepted either LiberalArts or Music school
   const int LiberalArtslimit = 5; // limits for counting accepted and total applicants
   const int Musiclimit = 3;
   int LiberalArtsNum, MusicNum;

   filename = "mp2accept.txt"; //opening file
       // conitinuing extracting data until end of the file
  
       if (LiberalArtsNum == LiberalArtslimit)// checking for availability of seats
       {
           cout << "Sorry there is no avaialble seats\n";
           return 1;
       }
       // Checking for other requirements includes GPA
       if ((GPA < 3.0 && Alumunus == 'Y') || (GPA < 3.5 && Alumunus == 'N'))
       {
       cout << "Rejected" << endl;// print a messsage 'GPA is too low for art school'
       }
   if ((Math + Verbal < 1000 && Alumunus == 'Y') || (Math + Verbal < 1200 && Alumunus == 'N'))
       {
           cout << "Rejected" << endl; //print a message'SAT is too low for art school'
       }
       else
       {
           cout << "Applicant is accepted to LiberalArts" << endl;
           LiberalArtsNum++; //counter for accepted applicant in LiberalArt school
       }
   }
   // iF appliacnt applied to Music school, checking requirements


   if (MusicNum == Musiclimit)// checking for availability of seats
   {
       cout << "Sorry there is no avaialble seats\n";
       return 1;
   }
   else if (Math < 500) {
       cout << "Rejected" << endl;// print a message'Math score is too low for admsission'
   }
   else if (Verbal < 500) {
       cout << "Rejected" << endl;// print a message'Verbal score is too low for admsission'
   }
   else
   {
       cout << "Accepted to Music" << endl;
       MusicNum++; // count applicants accepted in Music school
   }
   cout << "*******************************\n";
   //Print overall output
   cout << "There were" <<applicant count<< "Applicants in the file" << endl;
   cout << "There were" << LiberalArtsNum << "Applicants accepted in LiberaLArts" << endl;
   cout << "There were" << MusicNum << "Applicants accepted in Music School" << endl;
   return 0;

Solutions

Expert Solution

//Modified the code to have correct functioning.

//Be careful to place enter at the end of text file otherwise the code will not access the last element.

//START_PROGRAM

#include <iostream>
#include<fstream>
#include <sstream>
#include<string>
#include<iomanip>
using namespace std;


int main()
{
  
char school; // character variable for school and alumunus

int Math, Verbal; // Integer variable for SAT score
int SAT;
int applicant_count=1;
float GPA; // float variable for GPA
char Alumunus;// character variable for alumunus

// is the student accepted either LiberalArts or Music school
const int LiberalArtslimit = 5; // limits for counting accepted and total applicants
const int Musiclimit = 3;
int LiberalArtsNum=0, MusicNum=0;
  
   std::stringstream stream(std::stringstream::in | std::stringstream::out);   //to parse the string line into saperate variables.
  
  
int x;
string mp2accept,line;
ifstream inputFileX;
inputFileX.open("mp2accept.txt"); // this fstream is to read the data from the file
getline(inputFileX, line);
if (inputFileX.good() == false) {
cout << "Unable to open the file named " << mp2accept;
exit(1);
}
while (true) {
getline(inputFileX, line);
if (inputFileX.eof())
break;
cout << line << endl;
  
       stream <<line;           //sending line string to stream.
       stream>>school>>GPA>>Math>>Verbal>>Alumunus;       //getting saperate variables from stream.
       cout<<"Applicant #: "<< applicant_count;
   applicant_count++;  
       cout<<"School= "<<school<<" GPA= "<<GPA<<" Math="<<Math<<" Verbal="<<Verbal<<" Alumnus="<<Alumunus<<endl;   //showing each value saperately.
      
       if(school=='L')           //If applied to Liberal Arts school
       {
          
           cout<<"Applying to Liberal Arts"<<endl;
               if (LiberalArtsNum == LiberalArtslimit)// checking for availability of seats
   {
   cout << "Sorry there is no avaialble seats\n"<<endl;
   return 1;
   }
     
   int accepted2arts=1;       //0 means rejected to Arts. 1 means accepted. this flag is used to check the status of acceptance.
     
     
   // Checking for other requirements includes GPA
       if ((GPA < 3.0 && Alumunus == 'Y') || (GPA < 3.5 && Alumunus == 'N'))
   {
       cout << "Rejected: GPA is too low for Liberal Arts school"<<endl;
       accepted2arts=0;           //means that application is rejected.
   }
          if ((Math + Verbal < 1000 && Alumunus == 'Y') || (Math + Verbal < 1200 && Alumunus == 'N'))
   {
   cout << "Rejected: SAT is too low for Liberal Arts school"<<endl;
   accepted2arts=0;           //means that application is rejected.
   }
     
   if(accepted2arts==1)           //accepted2arts is still 1. this means that application is accepted.
   {
   cout << "Applicant is accepted to LiberalArts" << endl;
   LiberalArtsNum++; //counter for accepted applicant in LiberalArt school
   }
   cout << "*******************************\n";  
       }
  

if(school=='M')           // if applicant applied to Music school, checking requirements
   {
       cout<<"Applying to Music"<<endl;
       int accepted2mus=1;           //0 means rejected to take Liberal Arts. 1 means application accepted.
  
   if (MusicNum == Musiclimit)// checking for availability of seats
   {
   cout << "Sorry there is no avaialble seats\n";
   return 1;
   }
   else if (Math < 500) {
   cout << "Rejected: Math score is too low for admsission"<<endl;
   accepted2mus=0;                //means that application is rejected.
   }
   else if (Verbal < 500) {
   cout << "Rejected: Verbal score is too low for admsission"<<endl;
   accepted2mus=0;               //means that application is rejected.
   }
   if(accepted2mus==1)               //accepted2mus is still 1. this means that application is accepted.
   {
   cout << "Accepted to Music" << endl;
   MusicNum++; // count applicants accepted in Music school
   }
   cout << "*******************************\n";  
   }
  
}
//Print overall output
cout << "There were " <<applicant_count<< " Applicants in the file" << endl;
cout << "There were " << LiberalArtsNum << " Applicants accepted in LiberaLArts" << endl;
cout << "There were " << MusicNum << " Applicants accepted in Music School" << endl;
  
return 0;
}

//END_PROGRAM

INPUT FILE:

should be placed in the same folder.

L 4.0 600 650 N
M 3.9 610 520 N
L 3.8 590 600 N
L 3.0 600 600 Y
L 3.4 600 600 N
L 3.0 500 490 Y
L 2.9 500 500 Y
M 3.5 500 490 Y
M 3.9 490 600 Y
L 3.5 700 500 N
L 3.1 600 400 Y
L 3.0 490 510 Y
L 4.0 800 800 Y
M 3.2 500 500 N

OUTPUT:


Related Solutions

The Graduate Management Admission Test (GMAT) is a standardized exam used by many universities as part...
The Graduate Management Admission Test (GMAT) is a standardized exam used by many universities as part of the assessment for admission to graduate study in business. The average GMAT score is 547 (Magoosh website, January 5, 2015). Assume that GMAT scores are bell-shaped with a standard deviation of 100 . a. What percentage of GMAT scores are 647 or higher?    b. What percentage of GMAT scores are 747 or higher (to 1 decimal)?    c. What percentage of GMAT...
Many have called for the auditor’s report to be more informative and relevant therefore many changes...
Many have called for the auditor’s report to be more informative and relevant therefore many changes happened in the auditor report in the last five years. especially ISA 706 , which is about “Emphasis of Matter Paragraphs and Other Matter Paragraphs in the Independent Auditor’s Report. So you are required to show the reasons for the changes in ISA 706 and what is the impact of these changes on the auditor and other stockholders (Please write the answer so I...
Many have called for the auditor’s report to be more informative and relevant therefore many changes...
Many have called for the auditor’s report to be more informative and relevant therefore many changes happened in the auditor report in the last five years. especially ISA 701 , which is about “Communicating Key Audit Matters in the Independent Auditor’s Report. So you are required to show the reasons for the changes in ISA 701 and what is the impact of these changes on the auditor and other stockholders (Please write the answer so I can copy it)
If you had to decide on one health care system for the U.S., which system would...
If you had to decide on one health care system for the U.S., which system would you choose and why? Which three areas of the current U.S. health care system would you add to the system you have chosen for the U.S.? Explain why.
Decide which type of analysis should be used to compare the groups in each of the...
Decide which type of analysis should be used to compare the groups in each of the following studies. Choose from: T-test for two non-independent sample means; ANOVA; MANOVA; & Mann-Whitney . Explain your answers in well constructed sentences. a) Three 100-person groups were compared with regard to post-exercise heart rate. The groups were exposed to light, moderate and strenuous exercise, respectively. b) Two 50-patient groups were compared with regard to mean blood pressure before and after a diet intervention. The...
1.The procedure used to align many sequences at the same time is called: * diversity sequence...
1.The procedure used to align many sequences at the same time is called: * diversity sequence alignment multiple sequence alignment local alignment multiple statistical alignment substitution matrix alignment 2.The method of alignment that tries to align regions with high level matches without considering the alignment of the rest of the sequence is called: * global alignment multiple sequence alignment local alignment multiple statistical alignment high level matching alignment 3.The type of sequence alignments that is most suited for finding conserved...
The terms “irrelevance,” “dividend preference” (or “bird-in-the-hand”), and “tax effect” have been used to describe three...
The terms “irrelevance,” “dividend preference” (or “bird-in-the-hand”), and “tax effect” have been used to describe three major theories regarding the way dividend payouts affect a firm’s value. Explain these terms, and briefly describe each theory. What do the three theories indicate regarding the actions management should take with respect to dividend payouts? for me to give you a thumbs up I need a paragragh for each question.
Many small businesses have had to decide to whether close or remain in business during the...
Many small businesses have had to decide to whether close or remain in business during the recent pandemic. This is especially true of many local restaurants. Some have decided to adjust their services to take-out or delivery only, while others have decided to shutter completely or shut-down in the short-run. Assuming that the market for restaurant food is perfectly competitive and all restaurants face fixed costs in the short run for things such as rent or mortgage payments, describe why...
Many organizations have a general status called a " quality policy." This statement is often vague,...
Many organizations have a general status called a " quality policy." This statement is often vague, eg: the organization will supply the customer with "high quality". Obtain 3 example of such a statement and explain how it could be maid more specific. provide a source for each quality statement
8a) In Windows system programming, many system resources are represented as kernel objects, each of which...
8a) In Windows system programming, many system resources are represented as kernel objects, each of which is represented as a handle. Discuss with 3 examples how the system programmer can manipulate these handle objects. AP, 8 b) Write a C/C++ system program to move a file from one folder to another in the Windows file system. Compile and run the program and copy the source code into your answer booklet. CR,10 c) Compare and contrast processes and threads and discuss...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT