Guest User

Untitled

a guest
Jun 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class BlankScreen6 {
  3.  
  4.     public static void main(String[] args) {
  5.     //declare new integer array, calls
  6.     int[] calls;
  7.     //allocate memory for 7 integers
  8.     calls = new int[7];
  9.     //initialize array values
  10.     calls[0]=2;
  11.     calls[1]=9;
  12.     calls[2]=4;
  13.     calls[3]=7;
  14.     calls[4]=24;
  15.     calls[5]=9;
  16.     calls[6]=13;
  17.     //call displayData method with calls as an argument/parameter
  18.     displayData(calls);
  19.     System.exit(0);
  20.     }
  21.    
  22.     public static void displayData(int calls[]){
  23.         int highest=0;
  24.         for (int i=0; i<7; i++){
  25.             if (calls[i]>highest)
  26.                 highest=i;
  27.         }
  28.         System.out.println("The highest amount of calls was on day " + (highest+1) );
  29.     }
  30.    
  31. }
Add Comment
Please, Sign In to add comment