Program Kasir Sederhana || Dev C++|| Menggunakan do while, switch case, if else||
Summary
TLDRThis tutorial demonstrates how to create a simple cashier program using C++ with a do-while loop and switch-case for menu selection. The process begins by declaring variables for items, quantities, prices, and discounts. Users can choose from a list of 10 products, enter quantities, and calculate the total price. The program applies discounts based on the total amount and prompts the user to pay, calculating the change. The tutorial also includes handling invalid input and formatting the output. By the end, the user learns how to implement basic cashier functionality with simple C++ programming techniques.
Takeaways
- 😀 The script guides you through creating a simple cashier program in C++ using loops and conditionals.
- 😀 The program uses `do-while` loops to continuously prompt the user until they choose to exit.
- 😀 The `switch-case` structure is employed to display different items based on the user's choice.
- 😀 Variables such as `choice`, `quantity`, `price`, `total`, and `discount` are declared to handle the user input and calculations.
- 😀 The program displays a list of items and their corresponding prices, allowing the user to choose what to purchase.
- 😀 The total cost is calculated by multiplying the price of the item with the quantity the user chooses.
- 😀 Discounts are applied based on the total purchase: 6% for totals over 100,000, 4% for totals above 50,000, and 2% for totals up to 25,000.
- 😀 If the user's choice is invalid, the program will prompt the user to try again.
- 😀 After calculating the total and applying any discount, the user is asked for their payment, and the program calculates the change.
- 😀 The script ends with a thank-you message when the user chooses to exit the menu (option 10).
Q & A
What programming language is used for this cashier program?
-The cashier program is developed in C++ using the DevC++ IDE.
What is the purpose of the `do-while` loop in this program?
-The `do-while` loop ensures that the program continues to execute until the user chooses option 10 to exit the menu.
How is the menu displayed to the user in the program?
-The menu is displayed using `cout`, showing the item names and their respective prices, followed by prompts for user selection.
What is the role of the `switch-case` structure in this program?
-The `switch-case` structure is used to handle different menu options, ensuring the correct item is selected and its price is multiplied by the quantity entered.
How does the program calculate the total price for a selected item?
-The total price for a selected item is calculated by multiplying the price of the item by the quantity entered by the user.
What type of discount is applied based on the total purchase amount?
-The discount is applied based on the total purchase amount: 6% for totals of Rp100,000 or more, 4% for totals of Rp50,000 or more, and 2% for totals of Rp25,000 or more.
How does the program calculate the discount for the user?
-The discount is calculated by multiplying the total purchase amount by a specific percentage depending on the total amount: 0.06, 0.04, or 0.02.
What happens when the total amount is less than Rp25,000?
-If the total amount is less than or equal to Rp25,000, the program applies a 2% discount.
How does the program handle incorrect menu choices?
-If the user enters an incorrect menu option, the program will display an error message and prompt the user to select a valid option.
What happens when the user selects option 10 in the menu?
-When option 10 is selected, the program calculates the total, applies the discount, prompts the user for the payment, calculates the change, and then exits the loop, concluding the transaction.
Outlines

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифMindmap

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифKeywords

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифHighlights

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифTranscripts

Этот раздел доступен только подписчикам платных тарифов. Пожалуйста, перейдите на платный тариф для доступа.
Перейти на платный тарифПосмотреть больше похожих видео
5.0 / 5 (0 votes)