Advertisement
galinyotsev123

ProgBasicsExam3and4November2018-E05familyHouse

Jan 3rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E05familyHouse {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int mounths = Integer.parseInt(scanner.nextLine());
  8.  
  9. double electricityBill = 0;
  10. double average = 0;
  11. double waterBill = 20 * mounths;
  12. double internetBill = 15 * mounths;
  13. double otherBill = 0;
  14.  
  15. for (int i = 0; i < mounths; i++) {
  16. double electricity = Double.parseDouble(scanner.nextLine());
  17. electricityBill += electricity;
  18. otherBill = (electricityBill + waterBill + internetBill);
  19. otherBill *= 1.2;
  20. average = (electricityBill + waterBill + internetBill + otherBill) / mounths;
  21.  
  22. }
  23.  
  24.  
  25. System.out.printf("Electricity: %.2f lv%n", electricityBill);
  26. System.out.printf("Water: %.2f lv%n", waterBill);
  27. System.out.printf("Internet: %.2f lv%n", internetBill);
  28. System.out.printf("Other: %.2f lv%n", otherBill );
  29. System.out.printf("Average: %.2f lv%n", average);
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement