/*2016.9.16
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author 马康泰
*/
import java.util.Scanner;
public class Computr {
public static void main(String arg[]){
Scanner reader = new Scanner(System.in);
double amount=0;
double price = 0;
System.out.println("input the Electricity:");//输入电量
amount=reader.nextDouble();
if(amount <= 90&&amount>=1){
price=amount*0.6; //计算price的值
}
else if(amount <=150&&amount >=91){
price =90*0.6+(amount-90)*1.1; //计算price的值
}
else if(amount >150){
price = 90*0.6+(150-90)*1.1+(amount-150)*1.7; //计算price的值
}
else {
System.out.println("the input electricity"+amount+"is error.");
}
System.out.printf("Price:%5.2f", price);
}
}
【第三周】第三章实验1计算电费
最新推荐文章于 2023-12-24 10:07:31 发布