c++ homework help assignment 11

profilehomeworkhelp325
movieinfoapp.cpp

// MovieInfoApp.cpp #include "Movie.h" // include Movie class definition #include "Movies.h" // include Movies class definition #include <iostream> #include <iomanip> #include <string> using namespace std; void main() { Movies movies("Box Office Mojo.txt"); if(movies.getMovieCount() > 0) { string movieCode; cout << "Please enter the movie search string,\nentering a leading # to retrieve by movie number" << "\n or a ^ to get the next movie (press Enter to exit): "; getline(cin, movieCode); if (movieCode.length() > 0) { int mn = 0; const Movie * m; do { if(movieCode[0] != '#' && movieCode[0] != '^') m = movies.getMovie(movieCode, mn); else if(movieCode[0] == '#'){ // get by number mn = stoi(movieCode.substr(1)); m = movies[mn]; } else if(movieCode[0] == '^') // get next movie m = movies[++mn]; if(m != nullptr) { cout << *m << "\n"; if(m->getWorldBoxOffice() > 0) cout << setprecision(1) << fixed << "\n\tNon-US to World Ratio:\t" << (m->getNonUSBoxOffice() * 100.0) / m->getWorldBoxOffice() << "%\n" << endl; else cout << "No ratio due to zero World Box Office\n"; } else { cout << "\n Movie not found!\n\n" << endl; mn = 0; } cout << "Please enter the movie search string,\nentering a leading # to retrieve by movie number" << "\n or a ^ to get the next movie (press Enter to exit): "; getline(cin, movieCode); } while (movieCode.length() > 0); } } }