Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int months = sc.nextInt();
- double waterBill = 20;
- double internetBill = 15;
- double otherBills = 0;
- double waterBillCnt = 0;
- double internetBillCnt = 0;
- double electricityBillCnt = 0;
- double otherBillsCnt = 0;
- for (int i = 1; i <= months; i++) {
- double electricityBill = sc.nextDouble();
- electricityBillCnt += electricityBill;
- waterBillCnt += waterBill;
- internetBillCnt += internetBill;
- otherBills = (electricityBill + waterBill + internetBill) * 1.2;
- otherBillsCnt += otherBills;
- }
- double avg = (electricityBillCnt + waterBillCnt + internetBillCnt + otherBillsCnt) / months;
- System.out.printf("Electricity: %.2f $\n", electricityBillCnt);
- System.out.printf("Water: %.2f $\n", waterBillCnt);
- System.out.printf("Internet: %.2f $\n", internetBillCnt);
- System.out.printf("Other: %.2f $\n", otherBillsCnt);
- System.out.printf("Average: %.2f $\n", avg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement