import uwcse.io.Input; // use the Input class
import java.text.DecimalFormat; // to format the output
/**
* Homework 3
* Simulating a purchase in Canada paid in US dollars
*
* @author
*/
public class CanadianGiftShop {
// Constants
/** Exchange rate 1 US dollar = RATE Canadian dollar */
public final double RATE = 1.16;
/** Price of a jar of maple syrup in Canadian dollars before taxes */
public final double JAR_PRICE = 5.95;
/**
* Price of photograph of the city of Victoria in Canadian dollars before
* taxes
*/
public final double PHOTO_PRICE = 7.65;
/** Price of a beaver hat in Canadian dollars before taxes */
public final double HAT_PRICE = 16.35;
/** Maximum allowed number of purchased items for each item */
public final int MAX_ITEM = 100;
/** Tax rate */
public final double TAX_RATE = 0.093;
// instance variables
// number of purchased jars of maple syrup
private int jarNumber;
// number of purchased photographs of the city of Victoria
private int photoNumber;
// number of purchased beaver hats
private int hatNumber;
// 2 digits after the decimal point for doubles
private DecimalFormat twoDigits = new DecimalFormat("0.00");
// To input data from the user
private Input in = new Input();
/**
* Takes and processes the order from the customer
*/
public void takeAndProcessOrder() {
// Here is a possible series of steps: call some other (private)
// methods to do each step.
// Display the items and their prices
// Get the Customer's order
input();
// Get the user's USD payment
// Give the change back in Canadian dollars
double change = 13.2/7;
System.out.println(
"Change = " + twoDigits.format(change));
System.out.println("Change = " + change);
}
// Some ideas for some private methods
// You don't have to use exactly these same methods.
/**
* Displays the items for sale and their prices in Canadian dollars
*/
private void itemList() {
}
/**
* Gets the customer's order Precondition: none Postcondition: jarNumber,
* photoNumber and hatNumber are initialized to a value between 0 and
* MAX_ITEM
*/
private void input() {
jarNumber = in.readInt("How many jars of maple syrup would you like? ");
if (jarNumber < 0) {
System.out.println("You can't ask for a negative number");
jarNumber = 0;
}
if (jarNumber > MAX_ITEM) {
System.out.println("Sorry, we don't have that many in stock");
jarNumber = 0;
}
}
/**
* Given a purchase in canadian dollars and a payment in US dollars,
* displays the change amount in canadian dollars and cents
*
* @param payUS
* payment in US dollars
* @param costCA
* purchase amount in Canadia dollars
*/
private void changeinCAD(double payUS, double costCA) {
}
/**
* Entry point of the program
*/
public static void main(String[] args) {
new CanadianGiftShop().takeAndProcessOrder();
}
}