Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

College Admissions You have been hired by a small college to help automate their

ID: 3673175 • Letter: C

Question

College Admissions

You have been hired by a small college to help automate their admission process. The college has three schools -- Engineering, Liberal Arts, and Fine Arts. Each school has different entrance requirements and uses different criteria to select applicants. This makes it difficult to determine whether to Admit, Defer, or Deny each applicant. Having the necessary logic incorporated into a computer program will make this process much easier and help eliminate human error.

Requirements

For this project, you will write a program named Admissions that automates the admission selection process for a college. The college has a three schools —Engineering, Liberal Arts, and Fine Arts. All applicants submit an essay that is given a score ranging from 1 to 4. Applicants to the Engineering and Liberal Arts schools provide critical Reading and Math SAT scores while the Fine Arts applicants submit a portfolio instead — each portfolio is rated as Excellent, Good, Fair, or Poor. Based on the specific criteria listed below for each school, each applicant is given an admission status of "Admit", "Defer", or "Deny". However, applicants with an admission status of "Defer" who have two or more Alumni family members will be upgraded to "Admit" status.

Engineering School

Applicants with an essay score less than 2, a Math SAT score below 500, or a Reading SAT score below 400 will receive a "Deny" status. Other applicants who have a Math SAT score of 700 or better and a Reading SAT score of 600 or better will receive an "Admit" status while those with a Math SAT score of 500 or better and a Reading SAT score of 400 or better will receive a "Defer" status.

Liberal Arts School

Applicants with an essay score less than 3, a Math SAT score below 400, or a Reading SAT score below 500 will receive a "Deny" status. Other applicants who have a Math SAT score of 500 or better and a Reading SAT score of 650 or better will receive an "Admit" status while those with a Math SAT score of 400 or better and a Reading SAT score of 500 or better will receive a "Defer" status.

Fine Arts School

Applicants with an essay score less than 2, or a Portfolio rating of "Poor" or "Fair" will receive a "Deny" status. Other applicants who have a Portfolio rating of "Excellent" will receive an "Admit" status while those with a Portfolio rating of "Good" will receive a "Defer" status.


Your program must display a header that lists the name of the application and provides instructions about using the program. For example,

The user should be prompted for the following input values:

The applicant's name.

The school (E, L, F). The school must be entered as a single character. Both upper- and lowercase characters should be accepted.

The essay score (1 - 4).

If the school is Engineering or Liberal Arts, the user should be prompted for

Math SAT score.

Reading SAT score.

If the school is Fine Arts, the user should be prompted for

Portfolio rating (E, G, F, P). The rating must be entered as a single character. Both upper- and lowercase characters should be accepted.

Number of alumni family members.

The program should then output the applicant's admission status of Admit, Defer, or Deny.

Here are some examples; you must prompt the user for the input values in the same order as shown in the examples:

Error Handling

If the user enters an invalid school, an essay score below 1 or greater than 4, an SAT score below 200 or greater than 800, an invalid portfolio rating, or a negative integer for the number of alumni family members, the program should print "Invalid input" and immediately quit. HINT: The statement System.exit(1); will cause the program to quit with a status of 1 indicating an error condition. NOTE that you do not need to handle the situation where the user enters something other than an integer when an integer is expected. We will learn to handle this later in the semester.

Here are several examples of handling invalid input:

Design

The program must contain and use the completed version of the getAdmissionStatus() method below. You are free to define and use additional methods, if you like; be sure to provide Javadoc for them and include them in your structure diagram. Replace the comments below with appropriate Javadoc. See pp. 1110 - 1113 of the textbook or the course Style Guidelines for how to include a Javadoc @throws tag to document the IllegalArgumentException.

Even though you should do thorough error checking of the input values and exit the program as soon as an invalid value is entered, you must also do error checking of the parameter values within the getAdmissionStatus() methodand throw an IllegalArgumentException(), if any parameter value is invalid as described below. This requirement is simply to give you practice in checking method parameters and throwing exceptions. We will be testing that the exceptions are thrown. Please see the provided White Box Test program,AdmissionsTest.java, for an example of how we will test your program for the exception.

Implementation

Use named constants in your program rather than magic numbers. As of March 16, 2016, the SAT scoring structurewill change somewhat and the college may want to update their SAT score requirements. Defining the SAT-related values as constants will make this process easier for them.

NOTE that the process of validating the input values and exiting the program when an invalid value is entered istotally independent of checking the parameter values within the getAdmissionStatus() method and throwing an exception if a parameter value is invalid.

/**
* Program to test Admissions
*
* @author
*/
public class AdmissionsTest {

/** Constants for passing and failing test output */
public static final String PASS = "PASS";
public static final String FAIL = "FAIL";

/** Counters for test cases */
public static int testCounter = 0;
public static int passingTestCounter = 0;

/**
* Starts the test program
*
* @param args command line arguments
*/
public static void main(String[] args) {

testGetAdmissionStatus();

System.out.println(" ******** Results ********");
System.out.printf("%4d / %4d passing tests ", passingTestCounter, testCounter);

}

/**
* Prints the test information for tests whose actual result is an int.
*
* @param id id of the test
* @param desc description of the test (e.g., method call)
* @param exp expected result of the test
* @param act actual result of the test
*/
private static void testResult(String id, String desc, String exp, String act) {
testCounter++;
String result = FAIL;
if (exp.equals(act)) {
result = PASS;
passingTestCounter++;
}
System.out.printf(" %-25s%-55s%7s%46s%46s ", id, desc, result, exp, act);
}

/**
* Tests getAdmissionStatus method
*/
public static void testGetAdmissionStatus() {
// Example test case for getAdmissionStatus() method - e-ngineering low
// essay
String id = "e-ngineering low essay";
String desc = "Admissions.getAdmissionStatus('e', 1, 500, 500, ' ', 5)";
String expected = "Deny";
String actual = Admissions.getAdmissionStatus('e', 1, 500, 500, ' ', 5);
testResult(id, desc, expected, actual);

// Add 16 more *valid* test cases here for getAdmissionStatus() method

// Invalid test cases are provided for you below - You do NOT
// need to add additional invalid tests. Just make sure these
// pass!
id = "School X";
desc = "Admissions.getAdmissionStatus('X', 3, 500, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
String actualResult = "";
try {
actual = Admissions.getAdmissionStatus('X', 3, 500, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);

id = "Essay score too low";
desc = "Admissions.getAdmissionStatus('e', 0, 500, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 0, 500, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}

testResult(id, desc, expected, actualResult);
id = "Essay score too high";
desc = "Admissions.getAdmissionStatus('e', 5, 500, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 5, 500, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);

id = "Math SAT too low";
desc = "Admissions.getAdmissionStatus('e', 1, 100, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 1, 100, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}

testResult(id, desc, expected, actualResult);
id = "Math SAT too high";
desc = "Admissions.getAdmissionStatus('e', 3, 850, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 3, 850, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);

id = "Reading SAT too low";
desc = "Admissions.getAdmissionStatus('e', 1, 400, 100, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 1, 400, 100, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}

testResult(id, desc, expected, actualResult);
id = "Reading SAT too high";
desc = "Admissions.getAdmissionStatus('e', 2, 800, 900, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e',2, 800, 900, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);

id = "Portfolio x";
desc = "Admissions.getAdmissionStatus('F', 3, 0, 0, 'x', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('F', 3, 0, 0, 'x', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);

}

}

Explanation / Answer

Program:

/**
* Program to test Admissions
*
* @author
*/
public class AdmissionsTest {
/** Constants for passing and failing test output */
public static final String PASS = "PASS";
public static final String FAIL = "FAIL";
/** Counters for test cases */
public static int testCounter = 0;
public static int passingTestCounter = 0;
/**
* Starts the test program
*
* @param args command line arguments
*/
public static void main(String[] args) {
testGetAdmissionStatus();
System.out.println(" ******** Results ********");
System.out.printf("%4d / %4d passing tests ", passingTestCounter, testCounter);
}
/**
* Prints the test information for tests whose actual result is an int.
*
* @param id id of the test
* @param desc description of the test (e.g., method call)
* @param exp expected result of the test
* @param act actual result of the test
*/
private static void testResult(String id, String desc, String exp, String act) {
testCounter++;
String result = FAIL;
if (exp.equals(act)) {
result = PASS;
passingTestCounter++;
}
System.out.printf(" %-25s%-55s%7s%46s%46s ", id, desc, result, exp, act);
}
/**
* Tests getAdmissionStatus method
*/
public static void testGetAdmissionStatus() {
// Example test case for getAdmissionStatus() method - e-ngineering low
// essay
String id = "e-ngineering low essay";
String desc = "Admissions.getAdmissionStatus('e', 1, 500, 500, ' ', 5)";
String expected = "Deny";
String actual = Admissions.getAdmissionStatus('e', 1, 500, 500, ' ', 5);
testResult(id, desc, expected, actual);
// Add 16 more *valid* test cases here for getAdmissionStatus() method
// Invalid test cases are provided for you below - You do NOT
// need to add additional invalid tests. Just make sure these
// pass!
id = "School X";
desc = "Admissions.getAdmissionStatus('X', 3, 500, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
String actualResult = "";
try {
actual = Admissions.getAdmissionStatus('X', 3, 500, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
id = "Essay score too low";
desc = "Admissions.getAdmissionStatus('e', 0, 500, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 0, 500, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
id = "Essay score too high";
desc = "Admissions.getAdmissionStatus('e', 5, 500, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 5, 500, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
id = "Math SAT too low";
desc = "Admissions.getAdmissionStatus('e', 1, 100, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 1, 100, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
id = "Math SAT too high";
desc = "Admissions.getAdmissionStatus('e', 3, 850, 500, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 3, 850, 500, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
id = "Reading SAT too low";
desc = "Admissions.getAdmissionStatus('e', 1, 400, 100, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e', 1, 400, 100, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
id = "Reading SAT too high";
desc = "Admissions.getAdmissionStatus('e', 2, 800, 900, 'g', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('e',2, 800, 900, 'g', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
id = "Portfolio x";
desc = "Admissions.getAdmissionStatus('F', 3, 0, 0, 'x', 5)";
expected = "class java.lang.IllegalArgumentException";
actualResult = "";
try {
actual = Admissions.getAdmissionStatus('F', 3, 0, 0, 'x', 5);
} catch (IllegalArgumentException e) {
actualResult = "" + e.getClass();
}
testResult(id, desc, expected, actualResult);
}

//Admissions class that automates the admission selection process for a college.

private static class Admissions {

private static String getAdmissionStatus(char c, int e, int ms, int rs, char g, int an) {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

switch(c)
{
  
case 'E':
case 'e':
if(e<2 && ms<500 && rs<400)
return "Deny";
else if(e>2 && ms>=700 && rs>=600)
return "Admit";
else if(e>2 && ms>=500 && rs>=400)
return "Defer";
else
return "deny";
  
  
case 'L':
case 'l': if(e<3 && ms<400 && rs<500)
return "Deny";
else if(e>3 && ms>=500 && rs>=650)
return "Admit";
else if(e>3 && ms>=400 && rs>=500)
return "Defer";
else
return "deny";
  

case 'F':
case 'f': if(e<2 && g == 'p' && g == 'f')
return "Deny";
else if(e>2 && g == 'e')
return "Admit";
else if(e<2 && g == 'g')
return "Defer";
else
return "deny";
  
  
default:
  
  
}
return "";
}
}


}