Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. class TrafficData
  4.  
  5.     {
  6. public static void main(String[] args)
  7.  
  8.    {
  9.  
  10.    int[] vehicles=new int [7];
  11.  
  12.    String s;
  13.  
  14.    for (int i =0; i <vehicles.length; i++)
  15.  
  16.    {
  17.  
  18.   s=JOptionPane.showInputDialog(null,"Enter number of vehicles");
  19.        vehicles [i]= Integer.parseInt(s);
  20.  
  21.  
  22.        }
  23.    displaydata(vehicles);
  24.  
  25.        System.exit(0);
  26.  
  27.        }
  28.  
  29.      public static void displaydata(int vehicles[] )
  30.      {
  31.  int max=0;
  32.  
  33.      for (int i =0; i<7; i++)
  34.  
  35.     {
  36.  
  37.       System.out.println("The number of vehicles on day\t" + i + "="+ vehicles[i]);
  38.  
  39. if (max<vehicles[i])
  40.     max=vehicles[i];
  41.  
  42.   }
  43.    System.out.println("The Highest Traffic of the week is =" + max);
  44.  
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement