Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //6. Месечни разходи
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int months = scanner.nextInt();
- double electricityBill = 0.0;
- double electricityToPay = 0.0;
- double waterToPay = 0.0;
- double internetToPay = 0.0;
- double otherExpensesToPay = 0.0;
- for (int i = 1; i <= months; i++) {
- electricityBill = scanner.nextDouble();
- electricityToPay += electricityBill;
- waterToPay += 20;
- internetToPay += 15;
- otherExpensesToPay += (electricityBill + 20 + 15) * 1.2;
- }
- double averageMoneySpentPerMonth = (electricityToPay + waterToPay + internetToPay + otherExpensesToPay) / months;
- System.out.printf("Electricity: %.2f lv\n", electricityToPay);
- System.out.printf("Water: %.2f lv\n", waterToPay);
- System.out.printf("Internet: %.2f lv\n", internetToPay);
- System.out.printf("Other: %.2f lv\n", otherExpensesToPay);
- System.out.printf("Average: %.2f lv", averageMoneySpentPerMonth);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement