Cashier collection procedure, cashier collection
Subject requirements:
"" To write a cashier counter collection process.
"Requirements: receive the unit price, purchase quantity, and payment amount of the product entered by the user
"Calculates and outputs the commodity amount after off and the value of 0
Program Implementation
1 package cn.fury.test; 2 3 import java.util.Scanner; 4 5 public class Test{ 6 public static void main(String[] args) { 7 Scanner sc = new Scanner(System.in); 8 System.out.println("Please input the quantity of your goods:"); 9 int quantity = sc.nextInt();10 System.out.println("Please input the price of your goods:");11 float price = sc.nextFloat();12 System.out.println("Please input the payment amount:");13 float payment_amount = sc.nextFloat();14 System.out.println("The money that you should pay is :" + price * quantity);15 System.out.println("The money that the salesclerk should return you: " + (payment_amount - price * quantity));16 }17 }
View Code
Program Improvement Plan:
"The cashier can input multiple items. when entering the end, the input is ended.
"", Enter the price of each item in sequence, and the prompt is displayed before entering
"Calculates the total amount of all commodities
"" Determines the discount based on the total amount, no discount for less than 100, if more than 100, a 200 discount, more than 300
"Returns the total amount after the discount and the amount to be changed to zero
"Notice: Waiting for optimization ......