mrScarlett

ArraysWeights

May 9th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. import java.util.*;
  2. public class weightsArray
  3. {
  4.     public static void main (String args []){
  5.         Scanner input = new Scanner (System.in);
  6.         String [] namesArray = new String [5];
  7.         int [] startWeightsArray = new int [5];
  8.         int [] endWeightsArray = new int [5];
  9.         int [] weightDifferenceArray = new int [5];
  10.        
  11.         String name;
  12.         int startWeight;
  13.         int endWeight;
  14.         for (int x = 0; x<10;x++){
  15.            
  16.             System.out.println("Enter Name for person "+(x+1));
  17.             name = input.next();
  18.             namesArray[x]=name;
  19.            
  20.             System.out.println("Enter Start weight ");
  21.             startWeight = input.nextInt();
  22.             startWeightsArray[x]=startWeight;
  23.            
  24.             System.out.println("Enter End weight ");
  25.             endWeight = input.nextInt();
  26.             endWeightsArray[x]=endWeight;
  27.            
  28.             weightDifferenceArray[x]=startWeightsArray[x]-endWeightsArray[x];
  29.          
  30.         }
  31.        
  32.     for (int x=0;x<10; x++){
  33.             System.out.println("Student Name: "+namesArray[x]+" Weight difference "+weightDifferenceArray[x]);
  34.         }
  35.     }
  36. }
Add Comment
Please, Sign In to add comment