Advertisement
Guest User

Untitled

a guest
Sep 20th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package helpdavidpls;
  2.  
  3. /**
  4. ***********************************************
  5. @Author : David Pop
  6. @Last Modified: 9/19/2016
  7. @Description: This program is made to calculate change.
  8. ***********************************************
  9. */
  10.  
  11. import java.text.*;
  12. public class assignment1c{
  13.  
  14. public static void main (String[] args)
  15. {
  16. DecimalFormat a = new DecimalFormat ("###.##");// Formating for decimals
  17. DecimalFormat b = new DecimalFormat ("###");
  18.  
  19. Double purchasePrice = 10.99;//Assigning variables for: Price of item bought
  20. Double amountGiven = 20.00;//Amount given/paid
  21. Double totalPrice = purchasePrice * 1.13;//Total price including HST
  22. Double change = amountGiven - totalPrice;//Change
  23. Double hST = totalPrice - purchasePrice;//HST
  24.  
  25. Double fives = change / 5;
  26. Double dollars = change / 1;
  27. Double quarters = change / 0.25;
  28. Double dimes = change / 0.10;
  29. Double nickles = change / 0.05;
  30.  
  31. System.out.println ("Price: " + purchasePrice + " ");
  32. System.out.println ("Hst: " + a.format(hST));
  33. System.out.println ("Total: " + a.format (totalPrice));
  34. System.out.println ("Amount Paid: " + amountGiven+"");
  35. System.out.println ("Change: " + a.format(change));
  36. System.out.println ("Change Denomonations, Nickels: " + b.format(nickles) + ", Dimes: " + b.format(dimes) + ", Quarters: " + b.format(quarters) + ", Five Dollar Bills: " + b.format(fives) + ".");
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement