• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
91%
SHARE
TWEET

# Bills

totopopov Jun 19th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top