Guest User

Untitled

a guest
Oct 18th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public static void main(String[] args) {
  2. //Declare and Initialize Arrays and Scanner
  3. Scanner scan = new Scanner(System.in);
  4.  
  5. int num = 0;
  6. int[] array1;
  7. int highestgrade = 0;
  8.  
  9.  
  10. //Prompt user on how many grades they want to enter
  11. System.out.print("How many grades do you want to enter: ");
  12. num = scan.nextInt();
  13. array1 = new int[num];
  14.  
  15. for(int i = 0; i < array1.length; i++){
  16. System.out.print("Enter grade out of 100: ");
  17. array1[i] = scan.nextInt();
  18. }
  19.  
  20. //Traverse the array to find the highest grade entered
  21.  
  22. for (int i = 0; array1[0] < array1[i]; i++){
  23. System.out.print("Higher");
  24. }
  25.  
  26. //Display the results to the user
  27. System.out.print("The highest grade is " + highestgrade + ".");
  28.  
  29. //Close scanner
  30. scan.close();
  31.  
  32. }
Add Comment
Please, Sign In to add comment