Capítulo 7 - Estruturas de seleção encadeada II
Summary
TLDRThis video script demonstrates how to create an algorithm using the Portugol language to calculate the final price of a product based on various payment methods. The script covers a scenario where discounts are applied depending on the payment type: 25% for cash, 20% for check (30 days), 10% for credit card (2 installments), and 5% for credit card (3 installments). It outlines the steps for inputting the product price and payment code, applying the corresponding discount, and displaying the final amount. The tutorial offers a clear explanation of selection structures and simulates the program execution with sample inputs.
Takeaways
- 😀 The script explains the use of a chained selection structure to calculate the final price a customer must pay based on payment conditions.
- 😀 The algorithm requires the user to input the product's original price and the payment condition code.
- 😀 If the payment code is 0, a 25% discount is applied, indicating payment in full upfront (à vista).
- 😀 If the payment code is 1, a 20% discount is applied, indicating payment by check with a 30-day term.
- 😀 If the payment code is 2, a 10% discount is applied, indicating payment by credit card in two installments.
- 😀 If the payment code is 3, a 5% discount is applied, indicating payment by credit card in three installments.
- 😀 If the payment code is any value other than 0, 1, 2, or 3, no discount is applied and the original price is paid.
- 😀 The program structure uses conditional logic to check the payment code and apply the corresponding discount.
- 😀 The algorithm outputs the final price to be paid after applying the discount, depending on the selected payment condition.
- 😀 The script demonstrates the use of the 'se' (if) and 'senão' (else) structure to implement the selection process for various conditions.
- 😀 The example guides the user to simulate the algorithm with different prices and payment codes to see how the discount is applied.
Q & A
What is the goal of the algorithm described in the script?
-The goal of the algorithm is to calculate the price a customer has to pay based on the product's original price and the selected payment method, applying the appropriate discount.
What payment methods are supported in the algorithm?
-The algorithm supports four payment methods: 0 for cash (25% discount), 1 for check (30 days, 20% discount), 2 for credit card in two installments (10% discount), and 3 for credit card in three installments (5% discount).
What happens if the payment code entered is different from 0, 1, 2, or 3?
-If the payment code is different from 0, 1, 2, or 3, the algorithm assumes no discount and the customer pays the original price.
How does the algorithm calculate the discount for cash payment (code 0)?
-For cash payment (code 0), the algorithm applies a 25% discount by multiplying the original price by 0.75.
What discount is applied when the payment code is 1 (cheque for 30 days)?
-When the payment code is 1 (cheque for 30 days), the algorithm applies a 20% discount, meaning the customer pays 80% of the original price.
What is the discount when the payment code is 2 (credit card in two installments)?
-For code 2 (credit card in two installments), the algorithm applies a 10% discount, so the customer pays 90% of the original price.
How is the discount for code 3 (credit card in three installments) calculated?
-For code 3 (credit card in three installments), the algorithm applies a 5% discount, meaning the customer pays 95% of the original price.
What are the data types used for the variables in the algorithm?
-The algorithm uses the 'real' data type for the price variables (preco_original and preco_pagar) and the 'inteiro' data type for the payment code (codigo).
How does the algorithm handle the input and output of data?
-The algorithm prompts the user to enter the original price of the product and the payment method code. It then calculates the price to pay based on the discount rules and displays the final amount to the user.
Can the algorithm be adapted for other discount scenarios?
-Yes, the algorithm can be adapted by modifying the conditions and discount percentages in the selection structure to support other discount scenarios or payment methods.
Outlines

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowMindmap

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowKeywords

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowHighlights

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowTranscripts

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowBrowse More Related Video

How to Calculate a Discount and Sale Price | Math with Mr. J

4. Estructuras de selección

Anuitas || Matematika Wajib Kelas XI

AUMENTOS Y DESCUENTOS SUCESIVOS PORCENTUALES METODO GRAFICO Y ANALITICO

GAMPANG!!! CARA EDIT VIDEO IKLAN PRODUK DI CAPCUT !! | cara membuat video promosi produk di capcut

DisMath Week 10 Part 1: Basic Counting - Product Rule
5.0 / 5 (0 votes)