Day 03 focuses on applying Java conditional statements to real-world problems.
In this day, practical scenarios such as ATM withdrawal, e-commerce delivery, water usage, ticket pricing, salary bonus, shopping discounts, parking fees, and mobile recharge plans are implemented using Java.
The main goal is to improve logical thinking and understand how conditional statements are used in real-world applications.
if statementif-else statementelse-if ladderifScannerDay-03-Real-World-Conditions/
β
βββ README.md
β
βββ Questions/
β βββ Questions.txt
β
βββ Solutions/
β βββ Q01_ATM_Withdrawal.java
β βββ Q02_ECommerce_Delivery.java
β βββ Q03_Water_Usage_Charge.java
β βββ Q04_Water_Park_Ticket.java
β βββ Q05_Simple_Interest.java
β βββ Q06_Movie_Ticket.java
β βββ Q07_Employee_Bonus.java
β βββ Q08_Shopping_Discount.java
β βββ Q09_Parking_Fee.java
β βββ Q10_Mobile_Recharge.java
β
βββ Screenshots/
βββ Q01_ATM_Withdrawal.png
βββ Q02_ECommerce_Delivery.png
βββ Q03_Water_Usage_Charge.png
βββ Q04_Water_Park_Ticket.png
βββ Q05_Simple_Interest.png
βββ Q06_Movie_Ticket.png
βββ Q07_Employee_Bonus.png
βββ Q08_Shopping_Discount.png
βββ Q09_Parking_Fee.png
βββ Q10_Mobile_Recharge.png
Get the account balance and withdrawal amount from the user.
Conditions:
Display:
Get the order amount from the user.
Conditions:
Display the order amount, delivery charge, and final amount.
Get the number of water units used.
Conditions:
Calculate and display the total water bill.
Get the age of the customer.
Conditions:
Display the ticket price.
Get the principal amount, time in years, and customer type.
Customer types:
Interest rates:
Formula:
Simple Interest = (Principal Γ Rate Γ Time) / 100
Display the simple interest and total amount.
Get the customerβs age and show type.
Age conditions:
Base ticket price:
If the show type is IMAX, add Rs.100.
Display the final ticket price.
Get the employee salary and years of experience.
Conditions:
Display:
Get the shopping amount and customer membership type.
Membership types:
Discount rules:
| Membership | Amount β₯ Rs.5000 | Otherwise |
|---|---|---|
| Premium | 25% | 20% |
| Regular | 15% | 10% |
| Non-Member | 5% | No Discount |
Display the discount and final amount.
Get the number of hours a vehicle is parked.
Conditions:
Calculate and display the total parking fee.
Get the recharge amount.
Conditions:
Display the selected recharge plan.
| Question | Description | File |
|---|---|---|
| Q01 | Checks whether the user can withdraw money while maintaining the required minimum account balance | Q01_ATM_Withdrawal.java |
| Q02 | Calculates the delivery charge based on the order amount and displays the final amount | Q02_ECommerce_Delivery.java |
| Q03 | Calculates the water bill based on the number of units consumed | Q03_Water_Usage_Charge.java |
| Q04 | Calculates the ticket price based on the customerβs age | Q04_Water_Park_Ticket.java |
| Q05 | Calculates simple interest using different interest rates for student and general customers | Q05_Simple_Interest.java |
| Q06 | Calculates the movie ticket price based on age and show type | Q06_Movie_Ticket.java |
| Q07 | Calculates the employee bonus based on years of experience | Q07_Employee_Bonus.java |
| Q08 | Calculates the shopping discount based on the purchase amount and membership type | Q08_Shopping_Discount.java |
| Q09 | Calculates the parking fee based on the number of hours the vehicle is parked | Q09_Parking_Fee.java |
| Q10 | Displays the appropriate mobile recharge plan based on the recharge amount | Q10_Mobile_Recharge.java |
Scannerif, if-else, else-if, nested if)Open the Day-03-Real-World-Conditions folder in VS Code, Eclipse, or another Java-supported IDE.
Navigate to:
Day-03-Real-World-Conditions/Solutions/
Example:
javac Q01_ATM_Withdrawal.java
java Q01_ATM_Withdrawal
For other programs, replace the filename and class name with the required solution.
Screenshots of the program outputs can be added to the Screenshots/ folder.
Screenshots/
βββ Q01_ATM_Withdrawal.png
βββ Q02_ECommerce_Delivery.png
βββ Q03_Water_Usage_Charge.png
βββ Q04_Water_Park_Ticket.png
βββ Q05_Simple_Interest.png
βββ Q06_Movie_Ticket.png
βββ Q07_Employee_Bonus.png
βββ Q08_Shopping_Discount.png
βββ Q09_Parking_Fee.png
βββ Q10_Mobile_Recharge.png
By completing Day 03, you will:
if, if-else, and else-if statementsScannerDay 03 β Completed