11/04/2014

BCS2233 OOP. Lab 5/11/2014

(Finding the highest score) Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the student with the highest score.

import java.util.Scanner; 
public class lab5okt2014 {
    
    public static void main(String[] args) {
    int counter =1;
    Scanner input = new Scanner(System.in);
    System.out.println("sila masukkan jumpelajar");
    int jum_p= input.nextInt();
    System.out.println("sila masukkan nama dan markah");
        String maxNama= nama;
        int maxScore = score;
        
        while(counter<=jum_p){
        counter++;
        System.out.println("sila masukkan nama dan markah pelajar");
        nama = input.next();
        score = input.nextInt();
         if(score>maxScore){
         maxScore=score;
         maxNama=nama;
         }  // end utk if
        } // end utk while
   
       System.out.println("Pelajar dengan markah paling tinggi ialah : ");
       System.out.println(maxNama+maxScore);    
    } 
}


No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...