C++ Object oriented program help

Hi, so i'm completely lost in object oriented programming, and i thought that i could get some help on here. For my project i have to ask the user to first enter a "record" (just a plain text document with some words in it) that they would like to open, either "asn12_a.txt" or "asn12_b.txt". Now, after they enter one of these values, they will be prompted with a menu that asks them if they'd like to:

1. Display all lines in file
2. Display last 10 lines in file
3. Display all lines in file with line numbers
4. QUIT

Now, the user will be able to select one of these values and the program will go into the file, grab the lines (and add line numbers if necessary), and print them out for the user to see. This is the part i do not understand. Could anyone help? I'd greatly appreciate it!

Here's my code so far:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include<string>
#include<fstream>
using namespace std;

int main()
{
string record;
cout << "Enter name of record to pull: " << endl;
cin >> record;

if(record=="asn12_a.txt")
cout << "1. Display all records in file" << endl << "2. Display last 10 records in file" << endl << "3. all records with line numbers" << endl << "99. QUIT" << endl;
if(record=="asn12_b.txt")
cout << "1. Display all records in file" << endl << "2. Display last 10 records in file" << endl << "3. all records with line numbers" << endl << "99. QUIT" << endl;
else
cout << "ERROR, record does not exist." << endl;
cout << "Enter name of record to pull: " << endl;
cin >> record;

system("pause");
return 0;
}


There's also something wrong with my else loop, it only accepts two wrong values then the program aborts. also, it print out the contents of the else loop even if the correct value is entered, which doesn't make sense to me. Thanks again!
Topic archived. No new replies allowed.