Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java PLEASE DO NOT REUSE OLD CODE WRITE NEW CODE AND THUMBS UP WILL BE PROMISELY GIVEN. 1. Write a program that calculates the invoice
Java
PLEASE DO NOT REUSE OLD CODE WRITE NEW CODE AND THUMBS UP WILL BE PROMISELY GIVEN.
1. Write a program that calculates the invoice of each flat in the apartment building. There are N flats in a building and apartment heating is the central system. 30% of bill will be shared equally among the flats, the rest (70%) will be shared according to the consumption of each flat. Sample Calculation: Suppose that an apartment building has 3 flats Consumption of each flat (m): 12.8, 23, 9.2 Total Bill: 320.40 TL o 30% of bill: 96.12 TL o 70% of bill: 224.28 TL Then, the bill for each flat should be calculated as follows: o The bill for the Flat #1: 32.04 +63.80 = 95.83 TL o The bill for the Flat #2: 32.04 + 114.63 = 146.67 TL o The bill for the Flat #3: 32.04 + 45.85 = 77.89 TL Your program must have the following methods: public static void main(String[] args) Main method will take the inputs from the user. Then, it will invoke calculateTheInvoice () and printBills() methods, respectively. public static double[] calculateTheInvoice (double[] flats, double totalBill) You should calculate the bill of each flat based on the given sample calculation scenario. This method should take the following parameters: o A double array flats that indicates the consumption of each flat. o A double value totalBill that contains the total consumption of the whole apartment building. Then, the method should return a double array, which contains the calculated bill for each flat, to the main() method. public static void printBills (double[] bills) You should print the values to the console display. First input (N) is the number of flats in the apartment building. It is followed by N inputs for N flat consumption, and the last input is for the total bill. Input Format: N C1 C2 C3 .. Cn TotalBill Sample Input: 3 12.8 23 9.2 320.40 Here, N: the number of flats C1, C2, .. Cn: Consumption of each flat TotalBill: The total Bill for the apartment building. Example Run 1 (Input: 3 12.8 23 9.2 320.40) 3 12.8 23 9.2 320.40 Flat #1: 95.83 Flat #2: 146.67 Flat #3: 77.89 Example Run 2 (Input: 15 12 14.2 15.87 21.4 19 13 8.1 11 15.14 16 23.14 27 5.98 7.18 17 812.90) 15 12 14.2 15.87 21.4 19 13 8.1 11 15.14 16 23.14 27 5.98 7.18 17 812.90 Flat #1: 46.47 Flat #2: 52.0 Flat #3: 56.21 Flat #4: 70.13 Flat #5: 64.09 Flat #6: 48.98 Flat #7: 36.65 Flat #8: 43.95 Flat #9: 54.37 Flat #10: 56.54 Flat #11: 74.51 Flat #12: 84.23 Flat #13: 31.31 Flat #14: 34.33 Flat #15: 59.05 Example Run 3 (Input: 5 44.02 0 17 21.01 7.56 210.82) 5 44.02 0 17 21.01 7.56 210.82 1.Flat: 85.15 2.Flat: 12.64 3. Flat: 40.65 4. Flat: 47.25 5. Flat: 25.1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started