homework please due in an hour thirty

closed account (D9hk4iN6)
okay i have actually tried and here is the prompt and my code:


Write a program that reads student information from a file (one student per line) in the format:
StudentFirstName StudentLastName StudentID StudentTest1 StudentTest2 StudentTest3
and outputs them in the following format:
StudentLastName, StudentFirstNameInitial StudentID StudentTest1 StudentTest2 StudentTest3
where StudentFirstNameInitial is the initial (first letter) of the first name of student. Let us assume that the name
(StudentLastName, StudentFirstNameInitial) can be at most 15 characters, the StudentID can be at most 7
characters, and the StudentTest scores need up to 7 characters. The StudentTest scores should be formatted to have
exactly 2 decimals and should be aligned to the right. The rest of the values should be aligned to the left. Make sure you
are not missing any of the digits of the student ID. File.txt is an example of input file that you can use to test your
program.





// part 4.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>

using namespace std;


int main()
{


//declare variables
string a;
string b;
string c;

//read variables

cin >> a;
cin >> b;
cin >> c;
//write values to cout
cout << a;
cout << b;
cout << c;

//declare the file
ifstream in ("file1.txt");
//output file
ofstream out ("file2.txt");

//close if file does not open
if ( in.bad() )
{
cout <<"Error: could not open the input file file1.txt\n";
}
//read values from file1

in >> a;
in >> b;
in >> c;

//write values to file 2

out <<a;
out <<b;
out <<c;

return 0;
}
Topic archived. No new replies allowed.