Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, write a C++ program on the Linux system that keeps track of a set of superheroes. Instead of saving superhero information to

For this assignment, write a C++ program on the Linux system that keeps track of a set of superheroes. Instead of saving superhero information to a file like project 1, this time you will load your superhero information into memory, so they can be listed and searched. When the program starts, your program will ask the user to enter the name of an input file, which your program will open to load the hero information. The super hero information will be loaded into memory using an array of structs. The struct definition is listed below in a textbox. The input text file will use the same comma separated value format as project 1. You may only open the text file once, by calling loadHeroes() at the

Do not open the file in any other function other than loadHeroes (see below). After the data from the file is loaded, the program will enter a user-controlled loop. Inside of the loop, the program will ask the user what they want to do. In addition to searching and listing, the user will have the option to add another superhero to the database, but only to memory; do not add the new super hero information to the text file for this project. So, the options that the user can select are:

beginning of program execution.

Search for a superhero by name.

List all of the superheroes.

Add a new superhero to the memory database.

Quit.

struct heroInfo {

char heroName[STR_SIZE];

char realName[STR_SIZE];

char powers[STR_SIZE];

double firstAppear;

char creators[STR_SIZE];

char publisher[STR_SIZE];

There are 4 functions that you will be required to write for this project in addition to main: loadHeroes(), addAHero(), searchHeroes(), and listHeroes(). Call loadHeroes() when the program starts. Call the other functions inside of the user-controlled loop.

Example 2

Welcome to the superhero information program. What is the name of the superhero data file? superHeroes.txt

Successfully loaded 3 superheroes.

Name

Real Name

Powers

First Appear

Creators

Publisher

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

Black Panther

Ms Marvel

Spiderman

T'Challa

Kamala Khan

Miles Morales

Strength Speed and Previous Experience

Shape shifting and healing

Strength webs electric shock and sense

July 1966

August 2013

August 2011

Lee and Kirby

Amanat Whacker Wilson and Alphona

Bendis Pichelli and Alonso

Marvel

Marvel

Marvel

What would you like to do? (S)earch for a hero, (A)dd a hero, (L)ist all heroes, or (Q)uit? A

What is the name of the superhero? Superman

What is the real name of the superhero? Clark Kent

What powers does the superhero have? Impervious strength flight and others

Enter the year when the superhero first appeared: Nineteen Thirty-Eight Error, you must enter a number for the year: 1938

Enter the month when the superhero first appeared as an integer (1 - 12): 14

Error, you must enter an integer between 1 and 12 inclusive: 4

Who created the superhero? Siegel and Shuster

Who is the publisher? : DC Comics

Superman was successfully added to the database.

What would you like to do? (S)earch for a hero, (A)dd a hero, (L)ist all heroes, or (Q)uit? S

For what superhero would you like to search? Magneto

Magneto was not found in the database.

What would you like to do? (S)earch for a hero, (A)dd a hero, (L)ist all heroes, or (Q)uit? S

For what superhero would you like to search? Black Panther

Information on Black Panther is as follows:

Real Name: T'Challa, Powers: Strength Speed and Previous Experience, First Appear: July 1966, Creators: Lee and Kirby, Publisher: Marvel

What would you like to do? (S)earch for a hero, (A)dd a hero, (L)ist all heroes, or (Q)uit? L

Name

Real Name

Powers

First Appear

Creators

Publisher

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

Black Panther

Ms Marvel

Spiderman

Superman

T'Challa

Kamala Khan

Miles Morales

Clark Kent

Strength Speed and Previous Experience

Shape shifting and healing

Strength webs electric shock and sense

Impervious strength flight and others

July 1966

August 2013

August 2011

April 1938

Lee and Kirby

Amanat Whacker Wilson and Alphona

Bendis Pichelli and Alonso

Siegel and Shuster

Marvel

Marvel

Marvel

DC Comics

What would you like to do? (S)earch for a hero, (A)dd a hero, (L)ist all heroes, or (Q)uit? Q

Terminating Program.

Programming Requirements

Dont use the string library or any of the STL containers

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

Step: 3

blur-text-image

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

5. Is your hero motivated, at least in part, by guilt?

Answered: 1 week ago