Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Help please, using Microsoft Studio Write a C++ program that specifies three one-dimensional arrays named price, quantity and total. Each array should be capable
C++ Help please, using Microsoft Studio
Write a C++ program that specifies three one-dimensional arrays named price, quantity and total. Each array should be capable of holding 8 elements. Use a loop in the input function to read the values for the price and quantity arrays. The entries in the total array should be the product of the corresponding values in the price and quantity arrays (i.e. total[ i ] = price[ i ] * amount[ i ]). After all the data have been entered, display the following output:
Price
Quantity
Total
-----
--------
-----
a. Use main( ) as your driver function. Write main( ) so that it allows the user to run the program as many times as desired, as indicated by input from the user.
b. Write appropriate functions that main( ) calls to accomplish the following tasks:
1. Get the prices and quantities from the user (perform data validation on the users input),
2. Calculate the totals
3. Display the required output as shown below.
Hint: See pages 404 406, Using Parallel Arrays or Slides #41 - 45 in Chapter 7 PowerPoint Lecture Notes.
Sample Input:
This program computes the total price of different sale items based on the purchase price and the quantity of each item sold.
Please enter the price and quantity of 8 items.
Price of item 1 = ? 2.5
Quantity of item 1 = ? 3
Price of item 2 = ? 5.5
Quantity of item 2 = ? 4
Price of item 3 = ? 7.3
Quantity of item 3 = ? 6
Price of item 4 = ? 5
Quantity of item 4 = ? 6
Price of item 5 = ? 9
Quantity of item 5 = ? 4
Price of item 6 = ? 5
Quantity of item 6 = ? 8
Price of item 7 = ? 4
Quantity of item 7 = ? 32
Price of item 8 = ? 54
Quantity of item 8 = ? 4
Sample Output:
The sales summary is:
Price($) Quantity Total($)
--------- ---------- ---------
2.50 3 7.50
5.50 4 22.00
7.30 6 43.80
5.00 6 30.00
9.00 4 36.00
5.00 8 40.00
4.00 32 128.00
54.00 4 216.00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started