Anyone have any ideas?
Given Info:
Conway population is 55,000
There is a toilet for every 3 people in the population
Existing toilets use 15 liters of water
New toilets will use 2 liters of water
Each toilet is flushed 14 times per day
$350 per toilet to replace all toilets in city
costs $0.01 per liter of water
Find:
Cost to operate old vs new toilet per day?
Cost to replace all toilets in city?
How long will it take to recover replacement cost with water saved from using new toilets?
Here's my code:
I get errors on the following lines when I try to compile. I'm using jdk1.5.0Code://*********************************************************************************************** //Toilet.java Author: Jeremy S. Gates * // * //Calculates the cost of replacing all toilets in Conway, the operation cost of old toilets, * //the operation cost of new toilets, & the time required to recover the cost of replacing the * //old toilets with new ones. * //*********************************************************************************************** import java.text.DecimalFormat; //make DecimalFormat available import java.util.Scanner; //make scanner available public class Toilet { //start class public static void main (String args[]) //main method { //start method String userin; int pop; double repcost, oldopcost, newopcost, recovertime; DecimalFormat twoDigits = new DecimalFormat("0.00"); Scanner scan = Scanner.create(System.in); System.out.println ("Enter the population:"); //ask for input userin = scan.nextLine(); //read the input pop = Integer.parseInt(userin); //convert the input to an integer repcost = (pop/3) * 350; //calculates the replacement cost oldopcost = ((15*.01) * 14) * (pop/3); //calculates the operating cost of the old toilets newopcost = ((2*.01) * 14) * (pop/3); //calculates the operating cost of the new toilets recovertime = repcost/(oldopcost - newopcost) System.out.println ("The replacement cost = " +twodigits.format(repcost)); System.out.println ("The old toilet operation cost per day = $" +twodigits.format(oldopcos)); System.out.println ("The new toilet operation cost per day = $" +twodigits.format(newopcost)); System.out.println ("The recovery time in days = " +twodigits.format(recovertime)); System.exit(0); } //end of method } //end of class
This gives the error on the "." between Scanner and create. It says I gave a value and a class is expected.Code:Scanner scan = Scanner.create(System.in);
Also the following code gives an error on the "-" sign:
Any help is extremely appreciated. This is my last college semester and the instructor for this class is so bad that this is our FIRST assignment and there is about 5 weeks of class left! I hope to learn some Java on my own using the book and forums.Code:recovertime = repcost/(oldopcost - newopcost)


Reply With Quote