이 프로그램의 목적은 고객을 맞이하고 가격과 함께 판매 할 품목에 대한 정보를 제공 한 다음 고객이 원하는 각 품목의 양을 묻는 것입니다.영수증을위한 Java 프로그램
프로그램이 총계를 표시하고 고객이 지불하는 금액을 묻고 마지막으로 품목, 품목 가격, 수량, 제품 비용, 소계, 할인, 세금, 총액이 포함 된 영수증을 표시 할 수 있어야합니다 , 지불 및 고객의 변경.
T- 셔츠의 경우 $ 18.95, 감자 칩의 가방의 경우 $ 1.79, 12 팩 콜라 ($ 1.20 보증금)의 경우 $ 2.99입니다.
콜라를 제외한 모든 제품은 정가보다 15 % 할인 된 가격으로 판매되고 있습니다. 티셔츠에는 6 %의 미시간 판매 세가 부과됩니다.
저는 프로그램을 작성하고 자바를 사용하여 새로운 도움을받을 수있게되었습니다. 여기에 내가 코드에 대한 지금까지 쓴 것입니다 :
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);
}
}
지금 내 총 0 받고 있어요에 내가 입력을 입력하고 그것이 내가 내 변수 중 하나를 사용하지 않는 말할 때. 제품 수에 대한 입력 값은 무엇이든 될 수 있으며 고객이 받아야 할 총계 및 변경 사항을 올바르게 계산해야합니다. 여기
출력이 프로그램이 끝나고 실행하면 어떻게 보일지의 예입니다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!
샘플 입력, 예상 출력 및 실제 출력을 제공 할 수 있습니까? 귀하의 질문은 너무 광범위하고 그것은 이미 총을 인쇄하고있는 것 같습니다. –
나는 게시물을 편집하고 프로그램이 실행되면 출력이 어떻게 표시되는지 추가했습니다. –
현재 출력은 무엇입니까? 어떤 오류가 있습니까? – APerson