zoukankan      html  css  js  c++  java
  • 收银员收款程序

    》题目要求:

      》》编写一个收银柜台收款程序。
        》》》要求:接收用户输入的商品单价、购买数量以及用户付款的金额
        》》》计算并输出八折以后的商品金额和找零

    》程序实现

     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

    》程序改进方案:

      》》收银员可以输入多种商品,输入end时表示结束输入

      》》依次输入每种商品的价格,输入前提示是什么商品

      》》计算所有商品的总金额

      》》根据总金额决定折扣,100以下不打折,如果超过100就打8折,超过200就打7折,300以上打6折

      》》返回打折后的总金额以及找零金额

      》》notice : 待优化中......

  • 相关阅读:
    CC
    codeforces 984 E. Elevator
    codeforces 984 D. XOR-pyramid
    codeforces 984 C. Finite or not?
    codeforces 984 B. Minesweeper
    codeforces 984 A. Game
    Loj #6000. 「网络流 24 题」搭配飞行员
    2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest 训练报告
    省赛训练 分块9题
    AC自动机 hdu 2222 Keywords Search
  • 原文地址:https://www.cnblogs.com/NeverCtrl-C/p/6099440.html
Copyright © 2011-2022 走看看