Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
import java.util.Scanner;
public class Grade {
/**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
int sum=0, value, countA=0,countB=0,countC=0,countD=0,countF=0;
Scanner scan = new Scanner (System.in);
System.out.println("Please input your numeric grade(negative number for quit): ");
value=scan.nextInt();
while (value >=0)
{
if (value > 100){
System.out.println("Invalue input. Please reenter: ");
value=scan.nextInt();
}
else if (value >=90 && value <= 100){
countA++;
System.out.println("Your letter grade is: A");
}
else if (value >=80 && value <90){
countB++;
System.out.println("Your letter grade is B");
}
else if (value >= 70 && value <80){
countC++;
System.out.println("Your letter grade is C");
}
else if (value >=60 && value<70){
countD++;
System.out.println("Your letter grade is D");
}
else if (value <60){
countF++;
System.out.println("Your letter grade is F");
}
System.out.println("Please input your numeric grade:");
value=scan.nextInt();
}//end while
sum=countA+countB+countC+countD+countF;
System.out.println("Your total input " + sum + "times grade.");
System.out.println(countA + "  A's");
System.out.println(countB + "  B's");
System.out.println(countC + "  C's");
System.out.println(countD + "  D's");
System.out.println(countF + "  F's");
}//end of main
}