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