0% found this document useful (0 votes)
2 views2 pages

Algorithms

Uploaded by

arianimtiaz9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Algorithms

Uploaded by

arianimtiaz9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Algorithm 1: Coffee Shop Drink Price Estimator Program

1. Display a welcome banner.


2. Prompt the user for their name and age.
3. Determine discount rate based on age (child, student, senior, or none).
4. Display drink menu and ask the user to select one.
5. Assign base price and name according to the selected drink.
6. Ask user if they want each add-on (espresso, whipped cream, syrup).
7. Add add-on costs to compute subtotal.
8. Apply age-based discount and calculate discounted total.
9. Ask user to choose a tip percentage (0%, 10%, or 20%) and calculate tip.
10. Ask if user wants to round up total for donation and compute accordingly.
11. Display a formatted receipt showing all details: base drink, add-ons,
subtotal, discount, tip, donation, and final total.
12. Print a closing thank-you message and terminate the program.

Algorithm 2: Smart Restaurant Assistant Program


1. Display a welcome banner.
2. Display the main menu (options 1 through 6).
3. Prompt user to enter a menu choice.
4. Use a switch expression with yield to process the user’s selection:
- Case 1: Display today’s special meal and its price.
- Case 2: Calculate and display total cost of burger combo
(burger + fries + drink).
- Case 3: Ask for age and determine discount percentage based on age group
(under 12 → 50%, 12–25 → 20%, 65+ → 30%, others → 0%).
- Case 4: Ask for distance and display delivery charge based on range
(<10 → $5, 10–20 → $10, 20–30 → $20, >30 → not available).
- Case 5: Display restaurant opening hours.
- Case 6: Display closing message and terminate program.
- Default: Display “Invalid option” message for invalid inputs.
5. Print the result message from the switch expression.
6. Close the scanner and end the program.

You might also like