Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public class GerbilData {
  2. public static void main(String[] args){
  3. Scanner keyboard = new Scanner(System.in);
  4.  
  5. System.out.println("How many different food items do the gerbils eat?");
  6.  
  7. int n1 = keyboard.nextInt();
  8. Food[] gerbilFood = new Food[n1];
  9. String temp;
  10. int temp2;
  11. int count = 1;
  12.  
  13. for (int a = 0; a < n1; a++){
  14. gerbilFood[a] = new Food();
  15. }
  16.  
  17. int j = 0;
  18. while (j < n1){
  19. System.out.println("Name of food item " + count + ":");
  20. temp = keyboard.nextLine();
  21. gerbilFood[j].setName(temp);
  22. count++;
  23. j++;
  24. }
  25.  
  26. int n1 = keyboard.nextInt();
  27. keyboard.nextLine();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement