179k views
3 votes
Start

input testScore, classRank
if testScore >= 90 then
if classRank >= 25 then
output "Accept"
else
output "Reject"
endif
else
if testScore >= 80 then
if classRank >= 50 then
output "Accept"
else
output "Reject"
endif
else
if testScore >= 70 then
if classRank >= 75 then
output "Accept"
else
output "Reject"
endif
else
output "Reject"
endif
endif
endif
stop
Instructions
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).
start
input testScore, classRank
if testScore >= 90 then
if classRank >= 25 then
output "Accept"
else
output "Reject"
endif
else
if testScore >= 80 then
if classRank >= 50 then
output "Accept"
else
output "Reject"
endif
else
if testScore >= 70 then
if classRank >= 75 then
output "Accept"
else
output "Reject"
endif
else
output "Reject"
endif
endif
endif
stop

Below is the code to edit.

/* Program Name: CollegeAdmission.java
Function: This program determines if a student will be admitted or rejected.
Input: Interactive
Output: Accept or Reject
*/

import java.util.Scanner;
public class CollegeAdmission
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
// Declare variables






// Get input and convert to correct data type






// Test using admission requirements and print Accept or Reject
if( testScore >= 90 )
{
if( classRank >= 25)
{
System.out.println("Accept");
}
else
System.out.println("Reject");
}
else
{
if( testScore >= 80 )
{
if( classRank >= 50 )
System.out.println("Accept");
else
System.out.println("Reject");
}
else
{
if( testScore >= 70 )
{
if( classRank >=75 )
System.out.println("Accept");
else
System.out.println("Reject");
}
else
System.out.println("Reject");
}
}
} // End of main() method

} // End of CollegeAdmission class

1 Answer

0 votes

Answer:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

// Get the test score and class rank from the user

System.out.println("Please enter your test score: ");

int testScore = s.nextInt();

System.out.println("Please enter your class rank: ");

int classRank = s.nextInt();

// Determine whether to accept or reject the student

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 {

System.out.println("Reject");

}

}

}

User PurpleSmurph
by
7.1k points