/* Craig Persiko
   nameAverage.cpp
   Solution to CS 110A In-class exercise: Write a program that has 
   the user enter their full name (first and last name, with spaces) 
   into a single string variable. Then the user should enter 3 numeric 
   homework grades. The program should output the name and the average 
   of the grades, formatted to show just 1 digit after the decimal 
   point. Make sure to use a floating point data type for the grades. 

   This solution does one extra thing: it outputs the results to
   a file instead of the screen.
*/

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int main()
{
  char fullName[30];
  double grade1, grade2, grade3;
  ofstream fout;
  fout.open("nameAverageOutput.txt");

  cout << "Please enter your name: ";
  cin.getline(fullName, 30);

  cout << "Please enter your 3 grades: ";
  cin >> grade1 >> grade2 >> grade3;

  fout << "You are: " << fullName << " and your grade average is: ";
  fout << fixed << showpoint << setprecision(1);
  fout << (grade1 + grade2 + grade3) / 3 << endl;

  cout << "Results saved to nameAverageOutput.txt\n";

  return 0;
}




syntax highlighted by Code2HTML, v. 0.9