Answer to Question #18063 in C++ for paul

Question #18063
Write a C++ code that prompt the user to enter their name, age, class status (freshman,sophomore,junior,and senior) and GPA. Can the program write this information to a disk file as one item oer line?
Im having serious problems with this...
Thank you for your time.
1
Expert's answer
2012-11-06T12:09:47-0500
#include <string>
#include <iostream>
#include <fstream>
using namespace std;

int main () {
stringname, status;
intage, GPA;
cout<< "Enter name: " << endl;
cin>> name;
cout<< "Enter age: " << endl;
cin>> age;
cout<< "Enter status: " << endl;
cin>> status;
cout<< "Enter GPA: " << endl;
cin>> GPA;

ofstreammyfile;
myfile.open("example.txt");
myfile<< name << "
";
myfile<< age << "
";
myfile<< status << "
";
myfile<< GPA << "
";
myfile.close();
return0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS