60 683
Assignments Done
97,8%
Successfully Done
In April 2018

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.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions