Question: I need to be able to put in multiple records but when I try to put in more than one the initial cin statement for product name is ignored. I'm not sure what I'm doing wrong, a photo of what happens when I run the program is included. #include #include

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter7: User Creation And Management
Section: Chapter Questions
Problem 16MC
icon
Related questions
Question
100%

Question: I need to be able to put in multiple records but when I try to put in more than one the initial cin statement for product name is ignored. I'm not sure what I'm doing wrong, a photo of what happens when I run the program is included.

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main ()
{

ofstream w;
int c=1;

string filename;
cout << "File Name: ";
getline(cin, filename);
w.open(filename.c_str());

while(c==1){

string product_name;
cout << "Product name: ";
getline(cin, product_name,'\n');
w << product_name << endl;

double wppi; //wholesale price per item
cout << "Wholesale price: ";
cin >> wppi;
w << "Wholesale Price: " << wppi << " ";

int quanity;
cout << "Quanity: ";
cin >> quanity;
w << "Quanity: " << quanity << " ";

double total_price_paid;

total_price_paid = wppi * quanity;

double markup;
cout << "What is the markup? ";

cin >> markup;

double retail_price;
double anticipated_profit;

retail_price = wppi + markup;
anticipated_profit = total_price_paid - wppi;

w << "Retail Price: " << retail_price << " " << "Anticipated Profit: " << anticipated_profit << endl;

cout << "Do you want to process another record? Type 1 for Yes or 2 for No." <<endl;
cin >> c;

}

return 0;
}

[eddingjppolaris:-]S ./1ab7
File Name: Product.cpp
Product name: Apple
Wholesale price: 2
Quanity: 6
What is the markup? 3
Do you want to process another record? Type l for Yes or 2 for No.
1
Product name: Wholesale price: 3
Quanity: 4
What is the markup? 2
Do you want to process another record? Type 1 for Yes or 2 for No.
2
[eddingjp@polaris:~]$ |
Transcribed Image Text:[eddingjppolaris:-]S ./1ab7 File Name: Product.cpp Product name: Apple Wholesale price: 2 Quanity: 6 What is the markup? 3 Do you want to process another record? Type l for Yes or 2 for No. 1 Product name: Wholesale price: 3 Quanity: 4 What is the markup? 2 Do you want to process another record? Type 1 for Yes or 2 for No. 2 [eddingjp@polaris:~]$ |
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L