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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education