本文共 1255 字,大约阅读时间需要 4 分钟。
public class J5_8 { public static void main(String[] args) { // TODO Auto-generated method stub java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter the number of students: "); int student = input.nextInt(); String name = "ABC"; double score = 0; for(int i = 0;iscore) { score = scores; name = names; } } System.out.println("The higly score Student is: "+name+" score is "+score); }}
public class J5_9 { public static void main(String[] args) { // TODO Auto-generated method stub java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter the number of students: "); int student = input.nextInt(); String name = "ABC"; double score = 0; String name1 = "CBA"; double score1 = 0; for(int i = 1;i<=student;i++) { System.out.print("input the "+i+"Student information: "); double scores = input.nextDouble(); String names = input.nextLine(); if(scores >score) { score = scores; name = names; } else if(scores > score1) { score1 = scores; name1 = names; } } System.out.println("The higly score Student is: "+name1+" score is "+score1); System.out.println("The highest score Student is: "+name+" score is "+score); }}
转载地址:http://fubrn.baihongyu.com/