-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathElectricityBill.java
More file actions
18 lines (16 loc) · 767 Bytes
/
Copy pathElectricityBill.java
File metadata and controls
18 lines (16 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//A consumer consumes n watts per hour daily for one month.
// Calculate the total energy bill of that consumer if per-unit rate is 7?
// ( In $, £, €, INR, DHR, Riyal etc.) [Take 1 month = 30 Days].
package com.dsa;
import java.util.Scanner;
public class ElectricityBill {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the watts consumed per hour");
int watts=input.nextInt();
int electricity=watts*24*30;//Total watts of electricity consumed in 30 days
int cost=(electricity/1000)*7;//We divide by 1000 to convert watts to kilo-watts
//One unit=One kilo-watt and One unit costs 7
System.out.println("The electricity bill is "+cost);
}
}