전기 요금 계산기
package report;
import java.util.Scanner;
public class Elec {
// electric charge table
// 2013.11.21
final static float v1 = 60.7f;
final static float v2 = 125.9f;
final static float v3 = 187.9f;
final static float v4 = 280.6f;
final static float v5 = 417.7f;
final static float v6 = 709.5f;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int kwh;
int tmpCharge;
int vat; // value added tax
float eCharge = 0; // energy charge
int bCharge = 0; // basic charge
int eBaseFund = 0; // Electric Power Industry Base Fund
int mcr = 0; // monthly customer requisition
System.out.print("input kwh : ");
kwh = sc.nextInt();
int temp;
// basic charge
if (0 < kwh && kwh <= 100) {
bCharge = 410;
} else if (100 < kwh && kwh <= 200) {
bCharge = 910;
} else if (200 < kwh && kwh <= 300) {
bCharge = 1600;
} else if (300 < kwh && kwh <= 400) {
bCharge = 3850;
} else if (400 < kwh && kwh <= 500) {
bCharge = 7300;
} else {
bCharge = 12940;
}
// energy charge
temp = kwh;
if (temp >= 100) {
eCharge += (float) (100 * v1);
temp = temp - 100;
if (temp >= 100) {
eCharge += (float) (100 * v2);
temp = temp - 100;
if (temp >= 100) {
eCharge += (float) (100 * v3);
temp = temp - 100;
if (temp >= 100) {
eCharge += (float) (100 * v4);
temp = temp - 100;
if (temp >= 100) {
eCharge += (float) (100 * v5);
temp = temp - 100;
if (temp >= 0) {
eCharge += (float) (temp * v6);
} else {
eCharge += (float) (temp * v6);
}
} else {
eCharge += (float) (temp * v5);
}
} else {
eCharge += (float) (temp * v4);
}
} else {
eCharge += (float) (temp * v3);
}
} else {
eCharge += (float) (temp * v2);
}
} else {
eCharge += (float) (temp * v1);
}
tmpCharge = (int) (bCharge + eCharge);
vat = (int) Math.round(tmpCharge * 0.1);
eBaseFund = (int) ((tmpCharge * 0.037) / 10 * 10);
mcr = (int) (eCharge + bCharge + vat + eBaseFund) / 10 * 10;
// System.out.println("basic " + bCharge);
// System.out.println("tax " + eCharge);
// System.out.println("total " + tmpCharge);
// System.out.println("vat " + vat);
// System.out.println("eBaseFund " + eBaseFund);
System.out.println("output : " + mcr);
}
}