Advertisement
Deiancom

Bills

Feb 8th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Bills {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int months = Integer.parseInt(scanner.nextLine());
  7.  
  8.         double electricity = 0;
  9.  
  10.         for (int i = 1; i <= months  ; i++) {
  11.             double electricityBill = Double.parseDouble(scanner.nextLine());
  12.             electricity += electricityBill;
  13.            
  14.         }
  15.         double water = months * 20;
  16.         double internet = months * 15;
  17.         double others = electricity + water + internet;
  18.         double othersSum = others + others * 0.20;
  19.         double averageBill = (electricity + water + internet + othersSum) / months;
  20.         System.out.printf("Electricity: %.2f lv%n",electricity);
  21.         System.out.printf("Water: %.2f lv%n",water);
  22.         System.out.printf("Internet: %.2f lv%n",internet);
  23.         System.out.printf("Other: %.2f lv%n",othersSum);
  24.         System.out.printf("Average: %.2f lv",averageBill);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement