All Geektrust challenges are meant to be solved offline. Once you have completed the challenge, you can test and submit your code here. Your score will be determined based on factors such as OOPS, readability, and scalability.
You should read what we look for in your solution before you start coding. It is NOT about just getting the right output.
Please go through the build instructions here
The challenge
You work at WaterBill, a startup developing smart solutions for water management.
GeekHeights community has approached you to use your software to manage their water bills efficiently.
Each GeekHeights apartment is allotted with corporation and borewell water in a specific ratio at the start of the month. There are 2 bedroom and 3 bedroom apartments in the community and it is assumed that they will hold 3 and 5 people respectively.
Each person is allotted 10L of water per day. So a 2 BHK apartment will be allotted 900 L (3*10*30) of water per month and a 3 BHK apartment will be allotted 1500L (5*10*30) of water per month. The total water consumption is then split between corporation and borewell based on a ratio.
If there are additional guests in the apartment, the total allotted water will not suffice and the apartment has to ask for tanker water.
Costs
1. Corporation Water - Flat rate of Rs. 1 per litre
2. Borewell Water - Flat rate of Rs. 1.5 per litre
3. Tanker Water - Slab rate:
• 0 to 500L - Rs. 2 per litre
• 501L to 1500L - Rs. 3 per litre
• 1501 to 3000L - Rs. 5 per litre
• 3001L+ - Rs. 8 per litre
Tanker water has a slab rate similar to income tax slabs, which means you pay different amounts for each slab. For e.g if you have consumed 2000L of tanker water then your cost is 500*2 + 1000*3 + 500*5 = Rs. 6500
Your task
Find out the total cost of water for a month for an apartment.
Input Commands
ALLOT_WATER <apartment-type> <ratio>
Allots the water from corporation and borewell based on the apartment type and ratio passed. Here the ratio is always of the format Corporation Water : Borewell Water. This command will be executed only once a month per house and also at the start of the input command set.
Example- ALLOT_WATER 3 1:5
ADD_GUESTS <no_of_guests>
Adds the number of guests to a house. ADD_GUESTS command can be given multiple times in a month and total guests is the sum of all ADD_GUESTS numbers for that month.
Example - ADD_GUESTS 10
BILL
Prints the total water consumed in litres and the total cost, after cumulatively adding up all the guests cost to the bill. This command will be executed only once and at the end of the input set.
It should print the total water consumption and the cost in the format
<TOTAL_WATER_CONSUMED_IN_LITERS> <TOTAL_COST>
Example - BILL
4500 13625
Assumptions
1. All the calculations are done for a single apartment in a month. Number of days in the month is assumed to be 30.
2. The water consumption is measured in litres.
3. All calculations should be rounded off to the nearest integer. No decimal values are used.
4. Allotment based on ratio is done only once at the start of the month.
5. Guests can be added a multiple number of times.
6. The command BILL can be executed only once, which is at the end of the month. It should be a part of the input set.
SAMPLE INPUT-OUTPUT 1
INPUT:
ALLOT_WATER 2 3:7
ADD_GUESTS 2
ADD_GUESTS 3
BILL
OUTPUT:
2400 5215
SAMPLE INPUT-OUTPUT 2
INPUT:
ALLOT_WATER 3 2:1
ADD_GUESTS 4
ADD_GUESTS 1
BILL
OUTPUT:
3000 5750
SAMPLE INPUT-OUTPUT 3
INPUT:
ALLOT_WATER 2 1:2
BILL
OUTPUT:
900 1200
I am the exact one who can fulfill your task without fail.
I have 10 years of experience in developing We are team of 40+ Professionals who can help you for any software ,website , mobile apps and SEO/Google Ads/Facebook Ads Lead Generation, WhtsApp Marketing Panel , Crypto Projects We are offering free live demo if you are interested ping me back .