In this task, you need to identify the water bill for a household
User Task:
You have to input the total liter of water used by a house and output the total water bill. The water bill is calculated as follows:
For first 100 litres: Rs. 15 per litre
For next 100 litres: Rs. 14 per litre
After 200 litres: Rs. 12 per litre
Example
Input: 105
Output: 1570
Solution:–
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception {int sum=0; int min,min2; Scanner sc=new Scanner(System.in); int wat=sc.nextInt(); if(wat<=100){ sum=100*15; System.out.println(sum); } else if(wat>100 && wat<=200) { min2=wat-100; sum=(100*15)+(min2*14); System.out.println(sum); } else { min=wat-200; sum=(100*15)+(100*14)+(min*12); System.out.println(sum); } } }
Add a Comment