Wednesday, June 4, 2008

Nursery Program!

Today you are going to create a Plant class with the following information:

Cost

Name

Size

Quantity of plants

The nursery will create an array of plants (let's say they have 5 different types of plants).

The nursery class should keep track of:

Money taken in

Money spent on supplies

Plants on hand

The user should be able to update information about the plants and money that is coming in or out! Let's say the user should be able to update the quantity of certain plants available and the amount of money money taken in to the company!

Here's one way to loop using a trivial example:

Scanner a = new Scanner(System.in);

System.out.println("What would you like to do? [Quit] or [Deposit] $1000");

String ans = a.nextLine();

double deposit = 0;

while(!ans.equals("Quit")) //loop is going the basis

{

if(ans.equals("Deposit"))

{

deposit += 1000.0;

}

System.out.println("What would you like to do? [Quit] or [Deposit] $1000");

ans = a.nextLine();

}

System.out.println(deposit);

No comments: