Question: Star Database Program.(c++ for a beginner) Assignment.cpp is a starter that contains an int main function as well as some function prototypes. Your job is

Star Database Program.(c++ for a beginner) 
Assignment.cpp is a starter that contains an int main function as well as some function prototypes. Your job is to write out the prototyped functions completely. Do not change the int main function! When you are done the command ~cs1253_pet/bin/p_copy 3 will submit the contents of the prog3 directory for grading. by default the solution.o file is not executable, so you may need to make it executable. After copying it, the command: chmod a+x solution.o should make the file executable. Your program should use stars.dat as a data file for input and output. The solution program uses solution_stars.dat as a data file. stars.dat is formatted to contain information as follows, separated by commas: star name,star's constellation,star's apparent magnitude,star's mass, star's diameter,next star's name, next star's constellation.... I will always give you a file that contains information in these 5 value pieces, so a given star will always be followed by a value for constellation, apparent magnitude, mass and then diameter. Despite the fact that some of these values are numeric, it would probably be easiest to use strings as variables as you will not need to do any math. You do not have to test or worry about what happens if you start with a badly formed file. You DO have to ensure that you don't write to the file in such a way that it becomes malformed. This program will, on open, display a list of names gathered from a CSV file. The user will then select a name from that list, or "Add" or "Quit". The names may have spaces in them. If Quit is selected the program will end. If a name is selected, then details about that star will be printed, and then the menu will be reprinted. If Add is selected the program will prompt the user to enter information about a new star. Note! You must prohibit the user from entering the star's name as Add Quit or any name that is already in the file as a star name. Also! The star information must be added to the file, so that it will persist and be present the next time the program is run!. 

#include #include #include

using namespace std;

const int STAR_FACTS = 5; const int PREF_WIDTH = 23;

void PrintMenu(string fileName); //function needs to be prototyped

bool IsStarNameValid(string fileName, string starName); //function needs to be prototyped

void AddStarToFileFromUserInput(string fileName); //function needs to be prototyped

void PrintStarFacts(string fileName, string starName); //function needs to be prototyped

//Do not change anything below this line //you will lose points. That includes these comments. //EXACTMATCH int main(){ bool runProgram = true; string fileName = "stars.dat"; string userSelection; while(runProgram){ PrintMenu(fileName); cout << "Enter Star Name, or Add, or Quit: "; getline(cin, userSelection); if(userSelection == "Add"){ AddStarToFileFromUserInput(fileName); } else if(userSelection == "Quit"){ runProgram = false; } else{ if(IsStarNameValid(fileName, userSelection)){ PrintStarFacts(fileName, userSelection); } else{ cout << "Invalid Star Name "; } } } } //EXACTMATCH

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!