Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package helpdavidpls;
- /**
- ***********************************************
- @Author : David Pop
- @Last Modified: 9/19/2016
- @Description: This program is made to calculate change.
- ***********************************************
- */
- import java.text.*;
- public class assignment1c{
- public static void main (String[] args)
- {
- DecimalFormat a = new DecimalFormat ("###.##");// Formating for decimals
- DecimalFormat b = new DecimalFormat ("###");
- Double purchasePrice = 10.99;//Assigning variables for: Price of item bought
- Double amountGiven = 20.00;//Amount given/paid
- Double totalPrice = purchasePrice * 1.13;//Total price including HST
- Double change = amountGiven - totalPrice;//Change
- Double hST = totalPrice - purchasePrice;//HST
- Double fives = change / 5;
- Double dollars = change / 1;
- Double quarters = change / 0.25;
- Double dimes = change / 0.10;
- Double nickles = change / 0.05;
- System.out.println ("Price: " + purchasePrice + " ");
- System.out.println ("Hst: " + a.format(hST));
- System.out.println ("Total: " + a.format (totalPrice));
- System.out.println ("Amount Paid: " + amountGiven+"");
- System.out.println ("Change: " + a.format(change));
- System.out.println ("Change Denomonations, Nickels: " + b.format(nickles) + ", Dimes: " + b.format(dimes) + ", Quarters: " + b.format(quarters) + ", Five Dollar Bills: " + b.format(fives) + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement