Nackey

Bills

Aug 5th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1.     package com.company;
  2.  
  3.     import java.util.Scanner;
  4.  
  5.     public class Bills {
  6.         public static void main(String[] args) {
  7.             Scanner sc = new Scanner(System.in);
  8.  
  9.             int months = Integer.parseInt(sc.nextLine());
  10.             double water = 20;
  11.             double inet = 15;
  12.             double other = 0;
  13.             double totalEl = 0;
  14.             double procent = 0;
  15.             double totaaal = 0;
  16.             for (int i = 1; i <= months; i++) {
  17.                 double electro = Double.parseDouble(sc.nextLine());
  18.  
  19.                 totalEl += electro;
  20.  
  21.                 other = electro + water + inet;
  22.                 procent = other+(other*0.20);
  23.                 totaaal += procent;
  24.             }
  25.             double avarage = totaaal+totalEl+water*months+inet*months;
  26.             System.out.printf("Electricity: %.2f lv%n",totalEl);
  27.             System.out.printf("Water: %.2f lv%n",water*months);
  28.             System.out.printf("Internet: %.2f lv%n",inet*months);
  29.             System.out.printf("Other: %.2f lv%n",totaaal);
  30.             System.out.printf("Average: %.2f lv%n",avarage/months);
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment