An introduction to programming with c++ 8th edition ( Need the answer to be actu
ID: 3745604 • Letter: A
Question
An introduction to programming with c++ 8th edition ( Need the answer to be actually coded not written or typed ) RCompleting the Problem-Solving Process 5. Complete the C++ instructions column in Figure 4-32. C++ instructions IPO chart information Input tity sold 7. int quantity = 0; double cost 0.0 double sellPrice o.0 iten c item selling price Processing double difference-0.0 price and cost difference Output double profit-0.0; profit Algorithm: 1. enter the quantity sold, item cost, and item selling price difference by calculate swbtracting the item cost from the item selling price 2, the price and cost 3. calculate the profit by multiplying the price 4. display the profit and cost difference by the quantity sold coutExplanation / Answer
#include <iostream>
using namespace std;
int main() {
//Set i9nitial value to zero
int quantity= 0;
double cost= 0.0;
//Overall profit
double profit= 0.0;
double sellPrice= 0.0;
//Difference between sellPrice and cost
double difference= 0.0;
//1.Take data from console or terminal
cout << "Enter Quantity sold: ";
cin >> quantity;
cout << "Enter cost of the product: ";
cin >> cost;
cout << "Enter Selling price of the product: ";
cin >> sellPrice;
//2.Now calculate the difference between selling price and cost
difference=sellPrice-cost;
//3.overall profit is difference *quantity
profit=difference*quantity;
//4.Display profit on screen
cout<<"Profit: $" << profit<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.