Question: Programing Problem 1 An online retailer sells five products whose retail prices are as follows: Product 1, $2.98 Product 2, $4.50 Product 3, $9.98 Product

Programing

Problem 1

An online retailer sells five products whose retail prices are as follows:

Product 1, $2.98

Product 2, $4.50

Product 3, $9.98

Product 4, $4.49

Product 5, $6.87

Part A

Write a program that reads the quantity sold of each product and calculates and displays the total retail value of all products sold. Use a for loop to iterate through the products. Sample input/output:

Enter quantity sold of product 1: 2

Enter quantity sold of product 2: 6

Enter quantity sold of product 3: 3

Enter quantity sold of product 4: 7

Enter quantity sold of product 5: 1

Total $101.20

Part B

Rewrite problem 1 using a counter while loop.

Problem 4

Write a program with two functions: write_file and add_numbers. The write_file function will accept an integer and write that many random numbers between 1 and 30 inclusive to file randnumbers.txt. The add_numbers function will return the total of the numbers in the randnumbers.txt file. The main function will print the total. Sample output might be:

The total is 307

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!