All pastes #1223448 Raw Edit

Assignment1

public text v1 · immutable
#1223448 ·published 2008-10-09 05:07 UTC
rendered paste body
//Homework Assignment~Java City
// This program reads a text file and displays each record.

import java.util.Scanner;//Program uses class Scanner

public class JavaCity
{
   public void welcome()//Just a welcome call
   {System.out.println("Welcome to %s!", "My City");
   }
public void select()
{int Round=2;
int Population=0;
int Culture=0;
int Food=0;
int Productivity=0;
int Wealth=0;
int choice;
	Scanner input = new Scanner(System.in );
System.out.println("Round 1 [ Population: 0, Culture: 0, Food: 0, Productivity:0, Wealth: 0 ]\nPlease select:\n1. Add Professional\n2. Add Farmer\n3. Add Worker\n4. Add Businessman\n5. Leave the city");
System.out.printf("Your choice -->");
choice = input.nextInt();
if (choice ==1)
{Culture=Culture+1;Population=Population+1000;
Food=Food-1;
Productivity=Productivity-1;
System.out.println("Message: Adding 1000 professionals to the city.");}else
if (choice ==2)
{Population=Population+1000;
Food=Food+1;
System.out.println("Message: Adding 1000 farmers to the city.");}else
if (choice ==3)
{Population=Population+1000;
Food=Food-1;
Productivity=Productivity+1;
System.out.println("Message: Adding 1000 workers to the city.");}else
if (choice ==4)
{Population=Population+1000;
Food=Food-2;
Productivity=Productivity+1;
Wealth=Wealth+1;
	System.out.println("Message: Adding 1000 businessmen to the city.");
}else if (choice ==5)
System.out.println("Bye!");else {System.out.println("!!! Wrong input, Please try again. !!!");}
System.out.println();
	while (choice != 5){
System.out.printf("Round %d [ Population: %d, Culture: %d, Food: %d, Productivity: %d, Wealth: %d\n]", Round, Population, Culture, Food, Productivity, Wealth);
Round+=1;// +1 round 
System.out.println("Please select:\n1. Add Professional\n2. Add Farmer\n3. Add Worker\n4. Add Businessman\n5. Leave the city");
System.out.printf("Your choice -->");
choice = input.nextInt();
if (choice ==1)
{Culture=Culture+1;
Population=Population+1000;
Food=Food-1;
Productivity=Productivity-1;
System.out.println("Message: Adding 1000 professionals to the city.");}else
if (choice ==2)
{Population=Population+1000;
Food=Food+1;
System.out.println("Message: Adding 1000 farmers to the city.");}else
if (choice ==3)
{Population=Population+1000;
Food=Food-1;
Productivity=Productivity+1;
System.out.println("Message: Adding 1000 workers to the city.");}else
if (choice ==4)
{Population=Population+1000;
Food=Food-2;
Productivity=Productivity+1;
Wealth=Wealth+1;
	System.out.println("Message: Adding 1000 businessmen to the city.");
}else if (choice ==5)
System.out.println("Bye!");else {System.out.println("!!! Wrong input, Please try again. !!!");}
System.out.println();
}
} // end method select
} // end class JavaCity

/*************************************************************************
* (C) Copyright 1992-2007 by Deitel & Associates, Inc. and               *
* Pearson Education, Inc. All Rights Reserved.                           *
*                                                                        *
* DISCLAIMER: The authors and publisher of this book have used their     *
* best efforts in preparing the book. These efforts include the          *
* development, research, and testing of the theories and programs        *
* to determine their effectiveness. The authors and publisher make       *
* no warranty of any kind, expressed or implied, with regard to these    *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or       *
* consequential damages in connection with, or arising out of, the       *
* furnishing, performance, or use of these programs.                     *
*************************************************************************/