Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Assignment 12-Using C++ This lab is based on your lab assignment 10, the difference is that you are required to read from text files

Lab Assignment 12-Using C++

This lab is based on your lab assignment 10, the difference is that you are required to read from text files and write to text files, there are two text files, read.txt and write.txt, the code should read RUID and NAME from read.txt. After that user will choose as many options they like, write the options and results to wirte.txt, in the attachment, there is a sample read and write txt file.

The name and RUID is read from read.txt, if it find a string RUID in read.txt, you need to create a new Linkedlist to store the following RUID and name(there are multiple RUID in the string), finish reading all the elements in read.txt, use operator overloading + to connect linkedlists together. After that when user choose a option, the corresponding option and result will be written to write.txt

Reminder: make sure the text your code write to write.txt is the same as the example in write.txt

Also the sorting function is to sort by RUID also RUID is just a four digit-ID number.

Here is the example I/O in terminal

The combine list is as follow: (This comment is not part of the code what combine list means is creating 3 list objects list 1, list 2 and list 3. Then adding list1 and list 2 to equal list 3, so list1+list2=list3, this is the reasoning for overloading the + operator.)

RUID Name

4325 name1

5432 name2

6530 name3

1034 name4

2309 name5

Select the following options

1. Add node to list

2. Remove node from list

3. Print list

4. Print element of the list

5. Sort the list

6. Quit

Selection: 1

Enter student name: name6

RUID Name

4325 name1

5432 name2

6530 name3

1034 name4

2309 name5

4204 name6

Select the following options

1. Add node to list

2. Remove node from list

3. Print list

4. Print element of the list

5. Sort the list

6. Quit

Selection: 2 Enter the RUID to be removed: 1034

RUID Name

4325 name1

5432 name2

6530 name3

2309 name5

4204 name6

Select the following options

1. Add node to list

2. Remove node from list

3. Print list

4. Print element of the list

5. Sort the list

6. Quit

Selection: 4 Enter the index: 3

Node[3] = [2309 name5]

Select the following options

1. Add node to list

2. Remove node from list

3. Print list

4. Print element of the list

5. Sort the list

6. Quit

Selection: 5

RUID Name

2309 name5

4204 name6

4325 name1

5432 name2

6530 name3

Select the following options

1. Add node to list

2. Remove node from list

3. Print list

4. Print element of the list

5. Sort the list

6. Quit

Selection: 2 Enter the RUID to be removed: 1034

RUID not found

---------------------------------

read.txt

RUID Name 4325 name1 RUID Name 5432 name2 6530 name3 RUID Name 1034 name4 2309 name5 

write.txt

option: Add node to list Enter student name: name6 result: RUID Name 4325 name1 5432 name2 6530 name3 1034 name4 2309 name5 4204 name6 option: Remove node from list Enter the RUID to be removed: 1034 result: RUID Name 4325 name1 5432 name2 6530 name3 2309 name5 4204 name6 option: Print element of the list Enter the index: 3 Node[3] = [2309 name5] option: Sort the list result: RUID Name 2309 name5 4204 name6 4325 name1 5432 name2 6530 name3 option: Remove node from list Enter the RUID to be removed: 1034 result: RUID not found 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago