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

The first part of my code works fine (see below). The second part I need help on

ID: 3635933 • Letter: T

Question

The first part of my code works fine (see below). The second part I need help on is as follows:
Modify the application so that if a user enters a grade point average under 0 or over 4.0, or a test score under 0 or over 100, an error message appears instead of the "Accept" or "Reject" message.


import java.util.Scanner;
public class Admission
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
double gpa;
int score;

System.out.print("Please enter your grade point average: ");//input gpa
gpa=in.nextDouble();
System.out.print("Please enter your entrance score: ");//input score
score=in.nextInt();
accepted(gpa,score);
}
public static void accepted(double g,int s)
{//determine value of data
if(g<0||g>4.0||s<0||s>100)
System.out.println("Data invalid.");
else if((g>=3.0&&s>=60)||s>=85)
System.out.print("Accept");
else
System.out.print("Reject");

}//end class
}//end main

Explanation / Answer

Change System.out.println("Data invalid."); to System.err.println("Data invalid.");

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote