Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago