计算一个票据贴现的现金的JAVA语句
来源:百度知道 编辑:UC知道 时间:2024/06/13 22:17:21
Scenario情景:
You work in the IT company of Tianshi. This company is going to develop a business management system based on the Internet. You are a member of the development team and you are assigned the task of developing two components for this system你是开发小组的成员,你被派去开发此系统两部分组成的任务: one is for calculating the payment of a discount for a bill, and the other is for evaluating the input of a password. 一个是计算一个票据贴现的现金,另一个是评价一个密码输入。
The rule of the discount is上述优惠规则:
Total payment (Yuan) Percentage of Discount
Less than 100 0 % (No discount无折扣)
100 to 299(include 100 and 299) 5 %
300 to 499(include 300 and 499) 10 %
500 to 699(include 500 and 699) 15 %
More than 699 20 %
The input of this component is the total payment and the output is the actual payment after discount. 这一部分投入的总金额和输出是折扣后的实际支付。
You work in the IT company of Tianshi. This company is going to develop a business management system based on the Internet. You are a member of the development team and you are assigned the task of developing two components for this system你是开发小组的成员,你被派去开发此系统两部分组成的任务: one is for calculating the payment of a discount for a bill, and the other is for evaluating the input of a password. 一个是计算一个票据贴现的现金,另一个是评价一个密码输入。
The rule of the discount is上述优惠规则:
Total payment (Yuan) Percentage of Discount
Less than 100 0 % (No discount无折扣)
100 to 299(include 100 and 299) 5 %
300 to 499(include 300 and 499) 10 %
500 to 699(include 500 and 699) 15 %
More than 699 20 %
The input of this component is the total payment and the output is the actual payment after discount. 这一部分投入的总金额和输出是折扣后的实际支付。
package test;
import java.util.Scanner;
class Test{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("请输入总金额:");
Double total = input.nextDouble();
double discount = 0;
if( total.intValue()<100 )
{
discount=0.0;
}else if( total >= 100 && total <= 299 )
{
discount=0.05;
}else if( total >= 300 && total <= 499 )
{
discount=0.1;
}else if( total >= 500 && total <= 699 )
{
discount=0.15;
}else if( total > 699 )
{
discount=0.2;
}
System.out.println("打折后金额:"+(total-total*discount)+"元");
}
}