The purpose of the program is to print to greet the customer and then provide them with information on what is for sale along with the prices and then to ask how much of each item the customer wants.
After the program should be able to display the total and ask how much the customer is paying with and finally display a receipt containing the item, item price, quantity, the cost for the product, subtotal, discount, tax, total, payment, and the customer's change.
The list prices for the items at the store are: $18.95 for T-shirt, $1.79 for a bag of potato chips, and $2.99 for a 12-pack Coke ($1.20 deposit as well).
All merchandise except Coke is on sale with 15% off the list price. T-shirt is also charged a 6% Michigan sales tax.
I'm fairly new at writing programs and using java so all of the help would be appreciated. Here is what I have written so far for the code:
import java.util.Scanner;
//The purpose of this program is to simulate the shopping process by calculating the costs of the items
//and producing a receipt for the shopping trip.
//CPS 180
//Joseph Eastman
//September 24, 2014
public class StoreReceipt {
static final double TSHIRT_PRICE = 16.1075;
static final double CHIPS_PRICE = 1.5215;
static final double COKE_PRICE = 2.99;
String a;
static int numberShirts;
static int numberChips;
static int numberCoke;
static double tshirtTotal = TSHIRT_PRICE * numberShirts;
static double chipsTotal = CHIPS_PRICE * numberChips;
static double cokeTotal = (COKE_PRICE + 1.20) * numberCoke;
static double finalTotal = tshirtTotal + chipsTotal + cokeTotal;
{
}
private static Scanner input;
public static void main(String[] args) {
input = new Scanner(System.in);
System.out.println("What's your name?");
String a = input.nextLine();
System.out.println("Welcome to Denny's Market, " + a + "! We have the following items for sale:");
System.out.println("T-shirt $18.95 15% off");
System.out.println("Chips $1.79 15% off");
System.out.println("Coke $2.99");
System.out.println("How many T-shirts do you want?");
String numberShirts = input.nextLine();
System.out.println("How many bags of potato chips?");
String numberChips = input.nextLine();
System.out.println("What about 12-pack coke?");
String numberCoke = input.nextLine();
tshirtTotal = tshirtTotal * .85;
chipsTotal = chipsTotal * .85;
tshirtTotal = tshirtTotal * 1.06;
System.out.println("Your total is: " + finalTotal);
}
}
Right now when I type the inputs in I'm getting 0 for my total and it says I'm not using any of my variables. The inputs for the number of products can can be anything, it just has to correctly calculate the total and change the customer should receive.
Here is an example of what the output should look like when the program is finished and ran:
What’s your name? John
Welcome to Denny’s Market, John! We have the following items for sale:
T-shirt $18.95 15% off
Chips $ 1.79 15% off
Coke $ 2.99
How many T-shirts do you want? 3
How many bags of potato chips? 4
What about 12-pack Coke? 2
Your total is $65.69.
Please enter your payment: 70
John, here is your receipt:
item unit price how many cost
--------------------------------------------------------
T-shirt 18.95 3 56.85
Chips 1.79 4 7.16
Coke 2.99 2 5.98
Deposit 2.40
Subtotal 72.39
Discount -9.60
Tax 2.90
----------
Total 65.69
Payment 70.00
Your Change 4.31
Thank you. Come Again!