Question

Show data: Show Name (string- up to 25 characters, may not be blank) Show Date (mm/dd/yyyy, in that format) Show Fee to Participate (float, >-0) Show Sales (float, >-0) Miscellaneous Costs (float, >-0) Rate the Show(rating must be one of those 5 choices) Above maino, create a structure that will hold the information listed above. Then inside of main) create an array of 10 structures. Each structure in the array will represent a different show. Rules of the program: Option 1: Pass the array of structures to a function that inputs and validates as indicated above. Option 2: Pass the array of structures to a function that prompts the user for which show to edit and then prompts the user for what field to edit. Accept and validate the edit. Option 3. Pass the array of structures to a function that prompts the user for which show to display and then displays that show information. Validate for show existence Option 4. Pass the array of structures to a function that displays all show information AND the total sales (which your program will calculate) Option 5. Exist the program. Option 4 Sample Output: 4. Submit
media%2Fb23%2Fb2349418-91ea-4e51-ad47-fc
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
 
using namespace std;
 
struct shows
{
    string showName;
    string showDate;
    float fee;
    float sales;
    float misCost;
    string rateShow;
}mshows[10];
 
int count=0;
void readShowData();
void editShow(string sname);
void searchShow(string sname);
void displayShows();
 
int main()
{
    int ch;
    string showname;
    while(1)
    {
        cout<<"1. Input a Show\n2. Edit a Show\n3. Search for a show\n"
              "4. Display all shows with sales total\n5. Exit\n";
        cin>>ch;
        switch(ch)
        {
        case 1:
            readShowData();
            break;
        case 2:
            cout<<"enter show name to edit";
            cin>>showname;
            editShow(showname);
            break;
        case 3:
            cout<<"enter show name to search";
            cin>>showname;
            searchShow(showname);
            break;
        case 4:
            displayShows();
            break;
        case 5:
            return 0;
            break;
        }
    }
    return 0;
}
 
void readShowData()
{
    if(count >= 10)
    {
        cout<<"couldnt insert becuase accepted only 10 shows";
        return;
    }
    cout<<"Enter ShowName\n";
    cin>>mshows[count].showName;
    cout<<"Enter date in mm/dd/yyyy format\n";
    cin>>mshows[count].showDate;
    cout<<"Enter fee to participate\n";
    cin>>mshows[count].fee;
    cout<<"Enter show sales\n";
    cin>>mshows[count].sales;
    cout<<"Enter Miscellaneous cost\n";
    cin>>mshows[count].misCost;
    cout<<"Rate the show like * or ** or *** or **** or *****\n";
    cin>>mshows[count].rateShow;
    count++;
}
 
void editShow(string sname)
{
    int i;
    for(i=0; i<10; i++)
    {
        if(mshows[i].showName == sname)
            break;
    }
    if(i == 10)
    {
        cout<<"the show not exist";
        return;
    }
    string fieldname;
    cout<<"select which field to edit like showName, showDate, fee, sales, rateShow, Miscellaneous cost";
    cin>>fieldname;
    if(fieldname == "showName")
    {
        cout<<"Enter ShowName\n";
        cin>>mshows[i].showName;
    }
    else if(fieldname == "showDate")
    {
        cout<<"Enter date in mm/dd/yyyy format\n";
        cin>>mshows[i].showDate;
    }
    else if(fieldname == "fee")
    {
        cout<<"Enter fee to participate\n";
        cin>>mshows[i].fee;
    }
    else if(fieldname == "sales")
    {
        cout<<"Enter show sales\n";
        cin>>mshows[i].sales;
    }
    else if(fieldname == "rateShow")
    {
        cout<<"Rate the show like * or ** or *** or **** or *****\n";
        cin>>mshows[i].rateShow;
    }
    else if(fieldname == "Miscellaneous cost")
    {
        cout<<"Enter Miscellaneous cost\n";
        cin>>mshows[i].misCost;
    }
    else
    {
        cout<<"field dont match";
    }
}
 
void searchShow(string sname)
{
    int i;
    for(i=0; i<10; i++)
    {
        if(mshows[i].showName == sname)
        {
            cout<<"Show Name: "<<mshows[i].showName<<"\tShow Date: "<<mshows[i].showDate
               <<"\tfee: "<<mshows[i].fee<<"\tsales: "<<mshows[i].sales
              <<"\tRate Show: "<<mshows[i].rateShow<<"\tMiscellaneous cost: "<<mshows[i].misCost<<endl;
            return;
        }
    }
    if(i == 10)
    {
        cout<<"the show not exist";
        return;
    }
}
 
void displayShows()
{
    float totalsale=0;
    for(int i=0; i<10; i++)
    {
        if(mshows[i].showName != "")
        {
            totalsale += mshows[i].sales;
            cout<<"Show Name: "<<mshows[i].showName<<"\tShow Date: "<<mshows[i].showDate
                   <<"\tfee: "<<mshows[i].fee<<"\tsales: "<<mshows[i].sales
                  <<"\tRate Show: "<<mshows[i].rateShow<<"\tMiscellaneous cost: "<<mshows[i].misCost<<endl;
        }
    }
    cout<<"Totalsales is:"<<totalsale;
}
Output:
Add a comment
Know the answer?
Add Answer to:
Show data: Show Name (string- up to 25 characters, may not be blank) Show Date (mm/dd/yyyy,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program...

    PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program to hold information about the gemstones he has in his safe. Offer the jewelry designer the following menu that loops until he chooses option 4. 1. Input a gemstone 2. Search for a gemstone by ID number 3. Display all gemstone information with total value 4. Exit ------------------------------------- Gemstone data: ID number (int > 0, must be unique) Gem Name (string, length < 15)...

  • I am struggling with a program in C++. it involves using a struct and a class...

    I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...

  • In C Program This program will store the roster and rating information for a soccer team. There w...

    In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...

  • COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...

    COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see which professor has the highest rating according to student input. You will create a ProfessorRating class consisting of professor Name and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 being the lowest and 5 being the highest. Your program should contain the following functionalities:...

  • C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show...

    C++ program Correctly complete the following assignment. Follow all directions. The main purpose is to show super and sub class relationships with an array of super media pointers to sub class objects and dynamic binding. The < operator will be overloaded in the super class so all subclasses can use it. The selection sort method will be in the main .cpp file because it will sort the array created in main. The final .cpp file, the three .h header class...

  • Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839....

    Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...

  • Hw08FinalProjectStudentList.txt: (Data structure is Array List) 1,Simon,Jefferson,gy3085,4.0,2019 2,John,Johnson,xy1242,3.9,2019 3,Kayla,Anderson,as1324,3.8,2019 4,David,Kidman,re5423,3.8,2017 5,Mary,Coleman,ze7698,3.8,2018 Description: This assignment is

    Hw08FinalProjectStudentList.txt: (Data structure is Array List) 1,Simon,Jefferson,gy3085,4.0,2019 2,John,Johnson,xy1242,3.9,2019 3,Kayla,Anderson,as1324,3.8,2019 4,David,Kidman,re5423,3.8,2017 5,Mary,Coleman,ze7698,3.8,2018 Description: This assignment is going to evaluate your overall knowledge of the Java Programming. You shall implement a program which can store and retrieve student list. The program has a menu that you can take input from console, and the user can choose between the items. The program data is in the HwO8FinalProjectStudentList.txt file. Required Items: 1. The program must show a menu to user and ask the user...

  • WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL...

    WONT COMPILE ERROR STRAY / TEXT.H AND CPP PROGRAM SAYING NOT DECLARED HAVE A DRIVER WILL PASTE AT BOTTOM MOVIES.CPP #include "movies.h" #include "Movie.h" Movies *Movies::createMovies(int max) { //dynamically create a new Movies structure Movies *myMovies = new Movies; myMovies->maxMovies = max; myMovies->numMovies = 0; //dynamically create the array that will hold the movies myMovies->moviesArray = new Movie *[max]; return myMovies; } void Movies::resizeMovieArray() { int max = maxMovies * 2; //increase size by 2 //make an array that is...

  • In C++: Functions to include: editPlayer: is a void fn, which takes an array of playerType...

    In C++: Functions to include: editPlayer: is a void fn, which takes an array of playerType and calls lookUpPlayer which returns the index of the target (-1 if not found). If found allows the user to edit any of the data members of the player via a menu system. lookUpPlayer: is a int fn, which takes an array of playerTypes, prompts the user for the name of the player and attempts to find them. If found, prints message "found" and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT