View Code of Problem 70


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        double money;
        if(num<=100000)
            money = num*0.1;
        else if(num>100000&&num<=200000)
            money = (num-100000)*0.075+100000*0.1;
        else if(num>200000&& num<=400000) {
            money = (num-200000) * 0.05 + 100000 * 0.075 + 100000 * 0.1;
        }else if(num>400000 && num<=600000) {
            money = (num-400000) * 0.03 + 200000  * 0.05 + 100000 * 0.075 + 100000 * 0.1;
        }else if(num>600000 && num<=1000000) {
            money = (num-600000) * 0.015 + 400000 * 0.03 + 200000  * 0.05 + 100000 * 0.075 + 100000 * 0.1;
        }else {
            money = (num-1000000) * 0.01 + 600000 * 0.015 + 400000 * 0.03 + 200000  * 0.05 + 100000 * 0.075 + 100000 * 0.1;
        }
        System.out.println((int)money);
    }
}

Double click to view unformatted code.


Back to problem 70