1. Declare two string variables named testScoreString and classRankString 2. Dec
ID: 3807463 • Letter: 1
Question
1. Declare two string variables named testScoreString and classRankString
2. Declare two integer variables named testScore and classRank
3. Write the interactive input statement to recieve a students test score and class rank from the user of the program
4. Write the statement to convert the String representation of a student's test score and class rank to the integer data type.
Below is the basic program insert the data for the information above
/* Program Name: CollegeAdmission.java
Function: This program determines if a student will be admitted or rejected.
Input: Interactive
Output: Accept or Reject
*/
import javax.swing.JOptionPane;
public class CollegeAdmission
{
public static void main(String args[])
{
// Declare variables
int testScore;
String testScoreString;
int classRank;
String classRankString;
// 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
Explanation / Answer
HI, Please find my implementation.
Please let me know in case of any issue.
import java.util.Scanner;
/* Program Name: CollegeAdmission.java
Function: This program determines if a student will be admitted or rejected.
Input: Interactive
Output: Accept or Reject
*/
public class CollegeAdmission
{
public static void main(String args[])
{
// Declare variables
String testScoreString, classRankString;
int testScore, classRank;
// Get input and convert to correct data type
Scanner sc = new Scanner(System.in);
System.out.print("Enter test score string: ");
testScoreString = sc.next();
testScore = Integer.parseInt(testScoreString);
System.out.print("Enter class ranking string: ");
classRankString = sc.next();
classRank = Integer.parseInt(classRankString);
// 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
/*
Sample run:
Enter test score string: 60
Enter class ranking string: 87
Reject
*/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.