(3) Write another function named ReadGroceryList that reads the information from grocery.txt and displays the information on the screen like Item Cost Apple $4.5 Banana $1.20 (4) Your program must include your information and algorithm as specified in class

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Use this written code provided!!!
orty\Desktop\CS172 Spring CS172 C++\Projects (Submit for grading)\GrocieriesList\main.cpp - Dev-C++ 5.11
arch View Project Execute Tools AStyle Window Help
其山
TDM-GCC 4.9.2 32-bit Release
(globals)
ses
main.cpp
#include <iostream>
1.
#include <fstream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop /
5.
int main()
3.
4
6.
ofstream obj;
int choice, price;.
string itemName;
obj.open("grocery.txt"); //opening file in writing mode
8.
9
10
11
12
cout<<"1. Enter Groceries \n2. Show Groceries \n3. exit \n";
cout<<"Enter Your Choice:";
cin>>choice;
while(choice<3)
13
14
15
16
17 E {
18 E
19
if(choice--1){
cout << "Enter Grocery Item Name:";
cin >> itemName;
cout<<"Enter Grocery"<<"ItemName"<<"Cost";
cin >> price;
obj <« itemName <<"$"<<price<<endl; //writing data to file
20
21
22
23
24
25 É else if (choice--2){
string line;
ifstream myfile ("grocery.txt");
if ("myfile.isopen()")
26
27
28
29 E {
30
while(getline (myfile,line))
31 EA
32
cout <« line << '\n';
33
myfile.close();
35 F }
34
36
cout<<"\n1.Enter Groceries \n2. Show Groceries \n3. Exit\n";
cout<<"Enter Your Choice:";
cin>>choice;
37
38
39
40
41
obj.close(); //closing the file
42
43
44
return e;
45
mpiler
Resources db Compile Log V Debug O Find Results Close
----- ---
rt Compilation
Errors: o
Warnings:O
Output Filename: C:\Users\Shorty\Desktop\CS172 Spring CS172 C++\Projects (Submit for grading) \Grocierie.
- Output Size: 1.30378723144531 MiB
- Compilation Time: 2.50s
rten compiler path
33
Col:
2
Sel:
Lines:
45
Leng Insert
Done parsing in 0.031 seconds
>>
" main.cpp - Dev-C++
Transcribed Image Text:orty\Desktop\CS172 Spring CS172 C++\Projects (Submit for grading)\GrocieriesList\main.cpp - Dev-C++ 5.11 arch View Project Execute Tools AStyle Window Help 其山 TDM-GCC 4.9.2 32-bit Release (globals) ses main.cpp #include <iostream> 1. #include <fstream> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop / 5. int main() 3. 4 6. ofstream obj; int choice, price;. string itemName; obj.open("grocery.txt"); //opening file in writing mode 8. 9 10 11 12 cout<<"1. Enter Groceries \n2. Show Groceries \n3. exit \n"; cout<<"Enter Your Choice:"; cin>>choice; while(choice<3) 13 14 15 16 17 E { 18 E 19 if(choice--1){ cout << "Enter Grocery Item Name:"; cin >> itemName; cout<<"Enter Grocery"<<"ItemName"<<"Cost"; cin >> price; obj <« itemName <<"$"<<price<<endl; //writing data to file 20 21 22 23 24 25 É else if (choice--2){ string line; ifstream myfile ("grocery.txt"); if ("myfile.isopen()") 26 27 28 29 E { 30 while(getline (myfile,line)) 31 EA 32 cout <« line << '\n'; 33 myfile.close(); 35 F } 34 36 cout<<"\n1.Enter Groceries \n2. Show Groceries \n3. Exit\n"; cout<<"Enter Your Choice:"; cin>>choice; 37 38 39 40 41 obj.close(); //closing the file 42 43 44 return e; 45 mpiler Resources db Compile Log V Debug O Find Results Close ----- --- rt Compilation Errors: o Warnings:O Output Filename: C:\Users\Shorty\Desktop\CS172 Spring CS172 C++\Projects (Submit for grading) \Grocierie. - Output Size: 1.30378723144531 MiB - Compilation Time: 2.50s rten compiler path 33 Col: 2 Sel: Lines: 45 Leng Insert Done parsing in 0.031 seconds >> " main.cpp - Dev-C++
(3) Write another function named ReadGroceryList that
reads the information from grocery.txt and displays the
information on the screen like
Item
Cost
Apple $4.5
Banana $1.20
(4) Your program must include your information and
algorithm as specified in class
Transcribed Image Text:(3) Write another function named ReadGroceryList that reads the information from grocery.txt and displays the information on the screen like Item Cost Apple $4.5 Banana $1.20 (4) Your program must include your information and algorithm as specified in class
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY