MarcusV(南墙大佬的搬运工)

南墙大佬的CSDN博客地址

导航

Java实现 洛谷 P1422 小玉家的电费

在这里插入图片描述

import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner (System.in);
		
		int ele = in.nextInt();
		double out;
		
		
		if (ele <= 150) 
		{
			out = 0.4463*ele;
		}
		
		else if ((150 < ele) && (ele <= 400))
		{
			out = 66.945 + 0.4663 * (ele - 150);
		}
		
		else 
		{
			out = 150*0.4463 + 250*0.4663 + (ele - 400)*0.5663;
		}
	
		System.out.println(String.format("%.1f", out));
	
	
	}

}

posted on 2019-07-30 19:24  MarcusV  阅读(17)  评论(0)    收藏  举报