(File Processing - Writing) The same Bicycle shop that contracted you to write t
ID: 3767577 • Letter: #
Question
(File Processing - Writing) The same Bicycle shop that contracted you to write the double array problem in HW5 has now decided that they want to keep a log of all employee transactions. Write a program that will allow users to enter in their name (you only need to use first name) and the item that they sold (for example, “James Bicycle”). After each employee types in a sale, your program should record that sale in a file called sales.txt. Each sale should comprise one line of the sales.txt file (thus, be sure to use a after each sale). At the end of the day when the manager types in ‘quit quit’ the program should terminate.
Explanation / Answer
Your code is here:
#include <bits/stdc++.h>
using namespace std;
int main(){
ofstream inf;
inf.open("sales.txt");
string s,t;
while(true){
cin>>s;
if(s=="quit"){
break;
}
else{
cin>>t;
inf<<s<<" "<<t<<endl;
}
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.