Guest User

Bacon Eater

a guest
Sep 25th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. // ********************************************************
  2. // BaconEater.java
  3. //
  4. // Computes the price of a bacon given the weight
  5. // (in pounds) and price per pound -- prints a label,
  6. // nicely formatted, for the item.
  7. //
  8. // ********************************************************
  9. import java.util.Scanner;
  10.  
  11. public class BaconEater {
  12.     // ---------------------------------------------------
  13.     // main reads in the price per pound of the sales price
  14.     // and number of lbs of a bacon then computes
  15.     // the total price and prints a "label" for the item
  16.     // --------------------------------------------------
  17.     public static void main(String[] args) {
  18.         // create a pricePerPound variable of type double
  19.        
  20.         // create a weightPounds variable of type double
  21.        
  22.         // create a weight variable of type double
  23.        
  24.         // create a totalPrice variable of type double
  25.        
  26.         // create a Scanner object that takes in input from the keyboard
  27.  
  28.         // Declare money as a NumberFormat object and use the
  29.         // getCurrencyInstance method to assign it a value
  30.  
  31.         // Declare fmt as a DecimalFormat object and instantiate
  32.         // it to format numbers with at least one digit to the left of the
  33.         // decimal and the fractional part rounded to two digits.
  34.        
  35.         // prompt the user and read in each input
  36.        
  37.         // read in the price per pound
  38.        
  39.         // read in the weight
  40.        
  41.         // Compute the total price
  42.        
  43.         // Print the label using the formatting objects
  44.         // fmt for the weight in pounds and money for the prices
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment