Skor Tertinggi

Assalamualaikum, ..
Kali ini saya akan membagikan tentang skor tertinggi pada pemrograman java, . .
Selamat mencoba, . .

import java.util.Scanner;

public class HighestScore {

public static void main(String[] iriahus) {
@SuppressWarnings("resource")
Scanner s = new Scanner(System.in);

System.out.print("Enter the number of student: ");
int total = s.nextInt();

System.out.print("Enter the student's name followed by his/her score: ");
String name = s.next();
double score = s.nextDouble();

String studentMax = "";
double max = score;

int i = 1;

while (i < total) {
System.out.print("Enter the student's name followed by his/her score: ");
name = s.next();
score = s.nextDouble();
i++;

if (score > max){
studentMax = name;
        max = score;
        }
}

System.out.println(studentMax + " is the highest score of " + max);
}

}

Semoga bermanfaat, . .

Subscribe to receive free email updates:

0 Response to "Skor Tertinggi"

Post a Comment