Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Bills {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int months = Integer.parseInt(scanner.nextLine());
- double electricity = 0, water = 20.00, internet = 15.00, other = 0;
- for (int i = 0; i < months; i++) {
- double currentBill = Double.parseDouble(scanner.nextLine());
- electricity += currentBill;
- other += (currentBill + water + internet) * 1.2;
- }
- double average = (electricity + other) / months + water + internet;
- System.out.printf("Electricity: %.2f lv\n", electricity);
- System.out.printf("Water: %.2f lv\n", water * months);
- System.out.printf("Internet: %.2f lv\n", internet * months);
- System.out.printf("Other: %.2f lv\n", other);
- System.out.printf("Average: %.2f lv\n", average);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement