Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GerbilData {
- public static void main(String[] args){
- Scanner keyboard = new Scanner(System.in);
- System.out.println("How many different food items do the gerbils eat?");
- int n1 = keyboard.nextInt();
- Food[] gerbilFood = new Food[n1];
- String temp;
- int temp2;
- int count = 1;
- for (int a = 0; a < n1; a++){
- gerbilFood[a] = new Food();
- }
- int j = 0;
- while (j < n1){
- System.out.println("Name of food item " + count + ":");
- temp = keyboard.nextLine();
- gerbilFood[j].setName(temp);
- count++;
- j++;
- }
- int n1 = keyboard.nextInt();
- keyboard.nextLine();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement