HW09 Solution4

HW09 Solution4 - System.out.print("Which rat do you...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 import java.util.Scanner public class HW9_2 { public static void main(String[] args) { Rat[] family Scanner input = new Scanner(System.in) System.out.print("How many rats? ") int count = input.nextInt() family = new Rat[count] for (int j = 0 j < count j++) family[j] = new Rat() int ratIndex = 0 while (ratIndex != -1) { for (int j = 0 j < count j++) System.out.println("Rat #" + j + ": " + family[j].getWeight())
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.print("Which rat do you wish to change (-1 to quit)? ") ratIndex = input.nextInt() if (0 <= ratIndex && ratIndex < count) { System.out.print("What is the weight? ") int weight = input.nextInt() family[ratIndex].setWeight(weight) } System.out.println() // Optional blank line } } }...
View Full Document

This note was uploaded on 04/10/2008 for the course ENGR 131 taught by Professor Xiaowei during the Spring '07 term at Case Western.

Ask a homework question - tutors are online