handout #11

CSE142—Computer Programming I

Programming Assignment #4

due: Monday, 10/25/04, 9 pm

This assignment will give you practice with interactive programs and the use of some if/else statements.  You are to write a program that prompts the user for information about two applicants and that computes an overall score for each applicant.  This is a simplified version of a program that might be used for admissions purposes.

Look at the sample logs of execution to see how your program is to behave. Your program must exactly reproduce the behavior demonstrated in these logs.  For each applicant, we prompt for exam scores (either SAT or ACT) and overall GPA.  These numbers are used to compute an overall applicant score.  After obtaining scores for each applicant, the program reports which one looks better or it reports that they look equal.

Notice that the program asks for each applicant whether to enter SAT scores or ACT scores.  In the case of SAT scores, the user is prompted for SAT verbal and SAT math subscores.  In the case of ACT scores, the user is prompted for English, math, reading and science subscores.  These scores are turned into a number between 0 and 1 using the following formulas:

For SAT Scores: 

For ACT Scores: 

Your program then prompts for a GPA which we assume is on a 4-point scale.  This is also turned into a value between 0 and 1 by dividing it by 4.  The overall score for the applicant is computed as the sum of these two numbers-(exam result + gpa result).  Because each of these numbers is between 0 and 1, the overall score for an applicant ranges from 0 to 2.

You do not have to perform any error checking.  We will assume that the user enters numbers and that they are in the appropriate range.

In terms of program style you should use static methods to eliminate redundant code and to break the problem up into logical subtasks.  Your main method should be short so that a person can easily see the overall structure of the program.  You are to introduce at least four static methods other than main to break this problem up into smaller subtasks and you should make sure that no single method is doing too much work.  In this program, none of your methods should have more than 15 lines of code in the body of the method.  Be sure to once again include a short comment at the beginning of your program as well as a short comment for each method describing what it does.  Look at the program Judge2.java of handout #10 for a good example of eliminating redundant code and breaking a problem up into logical subtasks.

Your program should be stored in a file called Admit.java.  You will need to download the file Scanner.java from the class web page (under the “assignments” link) and store it in the same folder as your program.

First log of execution (user input underlined)

This program compares two applicants to

determine which one seems like the stronger

applicant.  For each candidate I will need

either SAT or ACT scores plus a GPA on a

4-point scale.

 

Information for the first applicant:

    do you have 1) SAT scores or 2) ACT scores? 1

    SAT math? 450

    SAT verbal? 530

    overall GPA? 3.4

 

Information for the second applicant:

    do you have 1) SAT scores or 2) ACT scores? 2

    ACT English? 25

    ACT math? 20

    ACT reading? 18

    ACT science? 15

    overall GPA? 3.3

 

First applicant overall score  = 1.4791666666666665

Second applicant overall score = 1.3583333333333334

The first applicant seems to be better

Second log of execution (user input underlined)

This program compares two applicants to

determine which one seems like the stronger

applicant.  For each candidate I will need

either SAT or ACT scores plus a GPA on a

4-point scale.

 

Information for the first applicant:

    do you have 1) SAT scores or 2) ACT scores? 2

    ACT English? 20

    ACT math? 19

    ACT reading? 21

    ACT science? 30

    overall GPA? 3.5

 

Information for the second applicant:

    do you have 1) SAT scores or 2) ACT scores? 1

    SAT math? 610

    SAT verbal? 640

    overall GPA? 3.6

 

First applicant overall score  = 1.4916666666666667

Second applicant overall score = 1.6875

The second applicant seems to be better

Third log of execution (user input underlined)

This program compares two applicants to

determine which one seems like the stronger

applicant.  For each candidate I will need

either SAT or ACT scores plus a GPA on a

4-point scale.

 

Information for the first applicant:

    do you have 1) SAT scores or 2) ACT scores? 1

    SAT math? 510

    SAT verbal? 530

    overall GPA? 3.4

 

Information for the second applicant:

    do you have 1) SAT scores or 2) ACT scores? 1

    SAT math? 570

    SAT verbal? 500

    overall GPA? 3.4

 

First applicant overall score  = 1.5041666666666667

Second applicant overall score = 1.5041666666666667

The two applicants seem to be equal