麻烦大神帮忙写个java小程序,谢谢
2个回答
展开全部
import java.util.Scanner;
public class test{
public static void main(String[] args) {
System.out.print("请输入用电度数:");
double pay ;
double power = new Scanner(System.in).nextDouble();;
if (power <=100) {
pay = power * 0.5;
}else if(power > 100 && power <= 200){
pay = (power - 100) * 0.8 + 50;
}else {
pay = (power - 300) * 1.5 + 130;
}
System.out.println("==================电费账单================");
System.out.println("用电度数 " +power + "度");
System.out.println("应交电费 " + pay + "元");
}
}
public class test{
public static void main(String[] args) {
System.out.print("请输入用电度数:");
double pay ;
double power = new Scanner(System.in).nextDouble();;
if (power <=100) {
pay = power * 0.5;
}else if(power > 100 && power <= 200){
pay = (power - 100) * 0.8 + 50;
}else {
pay = (power - 300) * 1.5 + 130;
}
System.out.println("==================电费账单================");
System.out.println("用电度数 " +power + "度");
System.out.println("应交电费 " + pay + "元");
}
}
展开全部
System.out.print("请输入电度");
char x=(char)System.in.read();//电量
double Cost = '';//费用
if(x<100)
Cost = x * 0.5;
else if(x <= 200)
Cost = (100 * 0.5 )+(x-100)*0.8;
else if(x > 200)
Cost = (100*0.5) + (100*0.8) + (X-200)*1.5;
System.out.println(Cost);
仅供参考。
char x=(char)System.in.read();//电量
double Cost = '';//费用
if(x<100)
Cost = x * 0.5;
else if(x <= 200)
Cost = (100 * 0.5 )+(x-100)*0.8;
else if(x > 200)
Cost = (100*0.5) + (100*0.8) + (X-200)*1.5;
System.out.println(Cost);
仅供参考。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询