public class ex001 { public static void main(String[] args) { int fre,eng,math,t
ID: 3611507 • Letter: P
Question
public class ex001 {
public static void main(String[] args)
{
int fre,eng,math,total,avg;
String w;
Scanner keyboard = new Scanner(System.in);
do{
do{
System.out.println("please enter the fre score: ");
fre = keyboard.nextInt();
}while(fre < 0 || fre > 100);
do{
System.out.println("please enter the eng score: ");
eng = keyboard.nextInt();
}while(eng < 0 || eng > 100);
do{
System.out.println("please enter math score: ");
math = keyboard.nextInt();
}while(math < 0 || math > 100);
total = fre + eng + math;
avg = total / 3;
System.out.println("total point is " + total );
System.out.println("the average score is " + avg);
System.out.println("Do you want to continue(Y/N): ");
w = keyboard.next();
}while(w == "n");
}
}
Explanation / Answer
please rate - this and the other one youowe me - thanks this will continue as long as a Y or y isentered, it will exit for anything else import java.io.*; import java.util.Scanner; public class ex001 { public static void main(String[] args) { int fre,eng,math,total,avg; String temp; char w; Scanner keyboard = new Scanner(System.in); do{ do{ System.out.println("please enter the fre score: "); fre = keyboard.nextInt(); }while(fre < 0 || fre > 100); do{ System.out.println("please enter the eng score: "); eng = keyboard.nextInt(); }while(eng < 0 || eng > 100); do{ System.out.println("please enter math score: "); math = keyboard.nextInt(); }while(math < 0 || math > 100); total = fre + eng + math; avg = total / 3; System.out.println("total point is " + total ); System.out.println("the average score is " + avg); System.out.println("Do you want to continue(Y/N): "); temp = keyboard.next(); w=temp.charAt(0); }while(w == 'Y'||w=='y'); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.