Advertisement
totopopov

Bills

Jun 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Created by Todor Popov using Lenovo on 19.6.2017 г. at 21:27.
  5.  */
  6. public class bills {
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner= new Scanner(System.in);
  10.         int months=Integer.parseInt(scanner.nextLine());
  11.         double electricitySum=0;
  12.         int water =20;
  13.         int net = 15;
  14.         double others =0;
  15.  
  16.         double totalSum=0;
  17.  
  18.         for (int i = 0; i < months; i++) {
  19.             double electricity=Double.parseDouble(scanner.nextLine());
  20.             electricitySum+=electricity;
  21.             double sum= 1.2*(electricity+net+water);
  22.             others+=sum;
  23.         }
  24.  
  25.         totalSum=electricitySum+others+(water+net)*months;
  26.  
  27.         double average=totalSum/months;
  28.         double totalWater=water*months;
  29.  
  30.         System.out.printf("Electricity: %.2f lv",electricitySum);
  31.         System.out.println();
  32.         System.out.printf("Water: %.2f lv",totalWater);
  33.         System.out.println();
  34.         System.out.printf("Internet: %.2f lv",1.0*net*months);
  35.         System.out.println();
  36.         System.out.printf("Other: %.2f lv",others);
  37.         System.out.println();
  38.         System.out.printf("Average: %.2f lv",average);
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement