/* Compute the price of an item priced by weight. */ import java.io.*; public class P1_2 { public static void main(String args[]) { double pounds; // number of pounds of item double pricePerPound; // price per pound of item double totalCost; // initialize Text object in to read from standard input. TokenReader in = new TokenReader(System.in); // prompt user for the number of pounds of the item System.out.print("How many pounds of the item do you have? "); System.out.flush(); pounds = in.readDouble(); // prompt user for the price per pound of the item System.out.print("What is the price per pound of this item? "); System.out.flush(); pricePerPound = in.readDouble(); // calculate and display cost of item rounded to two decimal places totalCost = pounds*pricePerPound; System.out.println("The total cost of your item is: " + (Math.floor(totalCost*100 + 0.5)/100) ); // Wait for user to enter input to ensure console window remains visible in.waitUntilEnter(); } // end main } // end P1_2 /* Sample outputs: ----------------------------------------------------------- How many pounds of the item do you have? 3.65 What is the price per pound of this item? 2.99 The total cost of your item is: 10.91 ----------------------------------------------------------- How many pounds of the item do you have? 1 What is the price per pound of this item? 2.457 The total cost of your item is: 2.46 */