
Write a program that will ask the user for 3 products and their prices to be input (carefully
choose appropriate data type and variables, total of 6 variables for input). After getting the input display a heading and then the products and prices in well-organized format. Part 2: Add the following to the above program. -Ask the user to enter how many items of each of the three product you want to purchase(integer variable) -Calculate the total for each product -Calculate the sub total for all product -Calculate 13% tax by multiplying sub total by 0.13 -Calculate the total by adding subtotal and tax -Display all information like an invoice

Ответы на вопрос

Ответ:
PL/SQL is a modern, block-structured programming language. It provides several features that make developing powerful database applications very convenient. For example, PL/SQL provides procedural constructs, such as loops and conditional statements, that are not available in standard SQL.
You can directly enter SQL data manipulation language (DML) statements inside PL/SQL blocks, and you can use procedures supplied by Oracle to perform data definition language (DDL) statements.
PL/SQL code runs on the server, so using PL/SQL lets you centralize significant parts of your database applications for increased maintainability and security. It also enables you to achieve a significant reduction of network overhead in client/server applications.



To write a program that asks the user for 3 products and their prices, and then displays the products and prices in a well-organized format, you can use the following steps:
1. Step 1: Prompt the user for input - Prompt the user to input the name and price of each product. - Use appropriate data types and variables to store the product names and prices. You will need a total of 6 variables for the input: 3 for the product names and 3 for the product prices.
2. Step 2: Display a heading and the products and prices - Display a heading to introduce the list of products and prices. - Use a loop to iterate over the 3 products and their prices. - Print each product name and its corresponding price in a well-organized format.
Here's an example of how the code for the first part of the program might look in Python:
```python # Step 1: Prompt the user for input product1_name = input("Enter the name of product 1: ") product1_price = float(input("Enter the price of product 1: "))
product2_name = input("Enter the name of product 2: ") product2_price = float(input("Enter the price of product 2: "))
product3_name = input("Enter the name of product 3: ") product3_price = float(input("Enter the price of product 3: "))
# Step 2: Display a heading and the products and prices print("Product\t\tPrice") print("---------------------") print(f"{product1_name}\t\t${product1_price}") print(f"{product2_name}\t\t${product2_price}") print(f"{product3_name}\t\t${product3_price}") ```
Now, to add the additional functionalities as mentioned in Part 2 of the program:
3. Step 3: Ask the user for the quantity of each product - Prompt the user to enter the quantity of each product they want to purchase. - Use integer variables to store the quantity of each product.
4. Step 4: Calculate the total for each product - Multiply the quantity of each product with its price to calculate the total cost for each product.
5. Step 5: Calculate the subtotal, tax, and total - Calculate the subtotal by summing up the total cost for all products. - Calculate the tax by multiplying the subtotal by 0.13 (assuming a tax rate of 13%). - Calculate the total by adding the subtotal and tax.
6. Step 6: Display all information like an invoice - Print a heading for the invoice, including the product, quantity, price, and total cost for each product. - Print the subtotal, tax, and total in a well-organized format.
Here's an example of how the code for the complete program might look in Python:
```python # Step 1: Prompt the user for input product1_name = input("Enter the name of product 1: ") product1_price = float(input("Enter the price of product 1: "))
product2_name = input("Enter the name of product 2: ") product2_price = float(input("Enter the price of product 2: "))
product3_name = input("Enter the name of product 3: ") product3_price = float(input("Enter the price of product 3: "))
# Step 2: Display a heading and the products and prices print("Product\t\tPrice") print("---------------------") print(f"{product1_name}\t\t${product1_price}") print(f"{product2_name}\t\t${product2_price}") print(f"{product3_name}\t\t${product3_price}")
# Step 3: Ask the user for the quantity of each product product1_quantity = int(input("Enter the quantity of product 1: ")) product2_quantity = int(input("Enter the quantity of product 2: ")) product3_quantity = int(input("Enter the quantity of product 3: "))
# Step 4: Calculate the total for each product product1_total = product1_price * product1_quantity product2_total = product2_price * product2_quantity product3_total = product3_price * product3_quantity
# Step 5: Calculate the subtotal, tax, and total subtotal = product1_total + product2_total + product3_total tax = subtotal * 0.13 total = subtotal + tax
# Step 6: Display all information like an invoice print("\nInvoice:") print("----------------------------------------") print("Product\t\tQuantity\tPrice\t\tTotal") print("----------------------------------------") print(f"{product1_name}\t\t{product1_quantity}\t\t${product1_price}\t\t${product1_total}") print(f"{product2_name}\t\t{product2_quantity}\t\t${product2_price}\t\t${product2_total}") print(f"{product3_name}\t\t{product3_quantity}\t\t${product3_price}\t\t${product3_total}") print("----------------------------------------") print(f"Subtotal\t\t\t\t\t\t${subtotal}") print(f"Tax (13%)\t\t\t\t\t\t${tax:.2f}") print("----------------------------------------") print(f"Total\t\t\t\t\t\t\t${total:.2f}") ```
This program will prompt the user for the names and prices of 3 products, then ask for the quantity of each product. It will calculate the total cost for each product, the subtotal, tax, and total, and display all the information in a well-organized invoice format.


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili