Question
C++ CodeBlocks wont allow me to print in letters for the genre such as FPS #include #include #include #include #include using namespace std; //Enum type
C++ CodeBlocks
wont allow me to print in letters for the genre such as FPS
#include
//Enum type of game enum type{A,B};
// Structure for video game struct videoGame { string title; type genre; int rank; double time; };
// Add game void addGame() { struct videoGame *v=new videoGame; ofstream out;
// Open the text file in append mode out.open("games.txt", std::ios_base::app); cin.ignore();
// Read the values from the user cout<<"Enter the title: "; getline(cin,v->title); int typ; cout<<"Enter the type: "; cin>>typ; if(typ==0) v->genre=A; else v->genre=B; cout<<"Enter the rank: "; cin>>v->rank; cout<<"Enter the time: "; cin>>v->time;
// Write it to the file out< // Function to print the gamne void printGame() { // Open the input file ifstream in; in.open("games.txt"); struct videoGame *v=new videoGame; cout<<"Title"<<"\t"<<"Type"<<"\t"<<"Rank"<<"\t"<<"Time"< // Read the file while(in>>v->title) { int typ; in>>typ; if(typ==0) v->genre=A; else v->genre=B; in>>v->rank; in>>v->time; // Print the information cout< // Calculate teh total time taken void totalTime() { ifstream in; double tim=0.0; in.open("games.txt"); struct videoGame *v=new videoGame; while(in>>v->title) { int typ; in>>typ; if(typ==0) v->genre=A; else v->genre=B; in>>v->rank; in>>v->time; // Add the time tim=tim+v->time; } cout<<"Total time taken :"< // Calculate the average rank void averageRank() { ifstream in; double ran=0.0; double avg; int count=0; in.open("games.txt"); struct videoGame *v=new videoGame; while(in>>v->title) { int typ; in>>typ; if(typ==0) v->genre=A; else v->genre=B; in>>v->rank; in>>v->time; // Total rank ran=ran+v->rank; count++; } avg=ran/count; cout<<"Average rank :"< // Function to edit the data file. // Ask the user to give the tiltle of the game // of which the dta has to be edited // Here the data edited is time void editData() { cin.ignore(); string tit; ifstream in; in.open("games.txt"); ofstream out; out.open("games1.txt"); cout<<"Enetr the title whose data to be changed: "; getline(cin,tit); cout< // Write back to the orginal file in.open("games1.txt"); out.open("games.txt"); while(in>>v->title) { int typ; in>>typ; if(typ==0) v->genre=A; else v->genre=B; in>>v->rank; in>>v->time; out< }while(ch!=6); // Pause the output terminal system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started