187k views
2 votes
In this lab, you use the flowchart and pseudocode found in the figure below to add code to a partially created Java program. When completed, college admissions officers should be able to use the Java program to determine whether to accept or reject a student, based on his or her test score and class rank.

Study the pseudocode in picture above.
Declare the variables testScoreString and classRankString.
Write the interactive input statements to retrieve:
A student’s test score (testScoreString)
A student's class rank (classRankString)
Write the statements to convert the string representation of a student’s test score and class rank to the integer data type (testScore and classRank, respectively).
The rest of the program is written for you.
Execute the program by clicking "Run Code." Enter 87 for the test score and 60 for the class rank.
Execute the program by entering 60 for the test score and 87 for the class rank.

User Evan Nagle
by
8.3k points

1 Answer

2 votes

Answer:

Step-by-step explanation:

To declare the variables ` testScoreString ` and ` classRankString ` and retrieve the student's test score and class rank, and convert them to integers, you can use the following code:

java: ```

import java.util.Scanner;

public class CollegeAdmission {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

String testScoreString, classRankString;

int testScore, classRank;

System.out.print("Enter your test score: ");

testScoreString = input.nextLine();

System.out.print("Enter your class rank: ");

classRankString = input.nextLine();

testScore = Integer.parseInt(testScoreString);

classRank = Integer.parseInt(classRankString);

if (testScore >= 90 && classRank >= 25) {

System.out.println("Accept");

} else if (testScore >= 80 && classRank >= 50) {

System.out.println("Accept");

} else if (testScore >= 70 && classRank >= 75) {

System.out.println("Accept");

} else if (testScore >= 60 && classRank >= 90) {

System.out.println("Accept");

} else {

System.out.println("Reject");

}

input.close();

}

} ```

To execute the program, you can click "Run Code" and then enter the test score and class rank when prompted. For example, for a test score of 87 and a class rank of 60, you would enter:

kotlin: ```

Enter your test score: 87

Enter your class rank: 60 ```

The program would output "Accept" since the student's test score and class rank meet the criteria for acceptance. If you entered a test score of 60 and a class rank of 87, the program would output "Reject" since the student's test score and class rank do not meet the criteria for acceptance.

User Eddie Groves
by
8.2k points