Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a menu system that read, writes and appends to a text file. You do not ne

ID: 3763286 • Letter: C

Question

Create a menu system that read, writes and appends to a text file.

You do not need to use arrays in this lab. You need to use functions as appropriate. This lab is not counted in the midterm grade.

The idea is to manage multiple lists of names stored on the disk. You can display and append any list of names stored from a main menu.

Main Menu:

Display the names in a list.

Add a name to a list.

[optional] Show all the lists.

Exit.

The program will display 'invalid option' if something not on the menu is selected.

If a valid option is selected, the program will do that option,

The program will continue to ask for choices until 'Exit' is selected, then the program will end.

If you ask for numbers as the options, I will only type in numbers. (cin >> nuInteger; has issues with letters, but that's not out problem)

Remember that getline() and cin >> do not always work well together!

Display the names in a list

When this option is selected the program will prompt for a file name. The program will then open the file and display the content of that file, 20 items at a time with a pause after the 20 names. You may assume that only text files will be displayed.

Allow the user to put both the filename and the extension, like party1.txt or mynames.list

If that file does not exist, you must display a message saying it doesn't exist, then go back to the menu.

If the file does exist, display the contents of the file 20 items at a time with a pause after the 20 names.

Add a name to a list

When this option is selected the program will prompt for a file name AND then prompt for a name. Names always contain an unknown amount of spaces, (see getline).

Allow the user to put both the filename and the extensions, like party1.txt or mynames.list

If the file does exist, the name will be APPENDED to the end of the file.

If that file does not exist, it will be created. (This will happen anyway with the append selected)

The user may put in any name with any number of spaces. (use getline, not >>)

Exit

When this option is pressed, the program ends. It should not end for any other reason. (Of course you can't control closing the window and things like that)

[optional] Show all the lists.


When this option is pressed, you can display the contents of the directory with all files ending in .txt and .list

This option is system specific, windows stuff won't work on linux, apple stuff wont work on windows, etc. Just put in the message area if you did this and what system you're using and I'll deal with it accordingly.

Text File Lab Instructions

Create a menu system that read, writes and appends to a text file.

You do not need to use arrays in this lab. You need to use functions as appropriate. This lab is not counted in the midterm grade.

The idea is to manage multiple lists of names stored on the disk. You can display and append any list of names stored from a main menu.

Main Menu:

Display the names in a list.

Add a name to a list.

[optional] Show all the lists.

Exit.

The program will display 'invalid option' if something not on the menu is selected.

If a valid option is selected, the program will do that option,

The program will continue to ask for choices until 'Exit' is selected, then the program will end.

If you ask for numbers as the options, I will only type in numbers. (cin >> nuInteger; has issues with letters, but that's not out problem)

Remember that getline() and cin >> do not always work well together!

Display the names in a list

When this option is selected the program will prompt for a file name. The program will then open the file and display the content of that file, 20 items at a time with a pause after the 20 names. You may assume that only text files will be displayed.

Allow the user to put both the filename and the extension, like party1.txt or mynames.list

If that file does not exist, you must display a message saying it doesn't exist, then go back to the menu.

If the file does exist, display the contents of the file 20 items at a time with a pause after the 20 names.

Add a name to a list

When this option is selected the program will prompt for a file name AND then prompt for a name. Names always contain an unknown amount of spaces, (see getline).

Allow the user to put both the filename and the extensions, like party1.txt or mynames.list

If the file does exist, the name will be APPENDED to the end of the file.

If that file does not exist, it will be created. (This will happen anyway with the append selected)

The user may put in any name with any number of spaces. (use getline, not >>)

Exit

When this option is pressed, the program ends. It should not end for any other reason. (Of course you can't control closing the window and things like that)

[optional] Show all the lists.


When this option is pressed, you can display the contents of the directory with all files ending in .txt and .list

This option is system specific, windows stuff won't work on linux, apple stuff wont work on windows, etc. Just put in the message area if you did this and what system you're using and I'll deal with it accordingly.

Explanation / Answer

i didnt understand exactly what is your requirment.but i treid

#include <iostream.h>
#include <fstream.h>
#include <conio.h>

staticint totalrec=0;   
scanned are Zerovoid main()
{
int ch ;
while(1)
{
clrscr();
cout<<"Choose your choice NOTE : one choice for one record ";
cout<<"1) Scanning intial records ";
cout<<"2) Appending records ";
cout<<"3) Modifying or append records ";
cout<<"4) Viewing records ";
cout<<"5) Exit ";
cout<<"Enter u r choice : ";
cin>>ch ;
switch (ch )
{
case 1 :   
{
ofstream outfile;
outfile.open("emp",ios::out);
cout<<" Please enter the details ";
cout<<" Enter the name : ";
char name[20];
cin>>name;
outfile<<name<<endl;
cout<<"Enter Age : ";
int age;
cin>>age;
outfile<<age<<endl;
cout<<"Enter programming language known by her : ";
char lang[25];
cin>>lang;
outfile<<lang<<endl;
totalrec= totalrec + 1;
outfile.close();
}
break;
case 2 : {
ofstream outfile;
outfile.open("emp",ios::app);
cout<<" enter the details as per rule ";
cout<<" Enter the name : ";
char name[20];
cin>>name;
outfile<<name<<endl;
cout<<"Enter Age : ";
int age;
cin>>age;
outfile<<age<<endl;
cout<<"Enter programming language known by him : ";
char lang[25];
cin>>lang;
outfile<<lang<<endl;
totalrec = totalrec + 1;
outfile.close();
}
break;
case 3 : {
ofstream outfile;
outfile.open("emp",ios::ate);
cout<<"Are you interested in adding record enter y or n ";
char ans;
cin>>ans;
if(ans=='y' || ans=='Y')
{
cout<<" enter the details as per demanded ";
cout<<" Enter the name : ";
char name[20];
cin>>name;
outfile<<name<<endl;
cout<<"Enter Age : ";
int age;
cin>>age;
outfile<<age<<endl;
cout<<"Enter programming language known by him : ";
char lang[25];
cin>>lang;
outfile<<lang<<endl;
totalrec = totalrec + 1;
}
outfile.close();
}
break;
case 4 : {
ifstream infile;
infile.open("emp",ios::in);
constint size=80;
char line[size];
int counter=totalrec;
while(counter > 0)
{
infile.getline(line,size);
cout<<" NAME : "<<line<<endl;
infile.getline(line,size);
cout<<"AGE : "<<line<<endl;
infile.getline(line,size);
cout<<"LANGUAGE : "<<line<<endl;
counter--;
}
infile.close();
}
getch();
break;
case 5 : gotoout;
default : cout<<" Invalid Choice TRY AGAIN ";
}
}
out:
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote