Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- //Declare and Initialize Arrays and Scanner
- Scanner scan = new Scanner(System.in);
- int num = 0;
- int[] array1;
- int highestgrade = 0;
- //Prompt user on how many grades they want to enter
- System.out.print("How many grades do you want to enter: ");
- num = scan.nextInt();
- array1 = new int[num];
- for(int i = 0; i < array1.length; i++){
- System.out.print("Enter grade out of 100: ");
- array1[i] = scan.nextInt();
- }
- //Traverse the array to find the highest grade entered
- for (int i = 0; array1[0] < array1[i]; i++){
- System.out.print("Higher");
- }
- //Display the results to the user
- System.out.print("The highest grade is " + highestgrade + ".");
- //Close scanner
- scan.close();
- }
Add Comment
Please, Sign In to add comment