Publicidad

Write a C++ program to compute numeric grades for a course- The course.docx

5 de Feb de 2023
Write a C++ program to compute numeric grades for a course- The course.docx
Write a C++ program to compute numeric grades for a course- The course.docx
Próximo SlideShare
Write a program to compute average quiz scores for a course- The cours.pdfWrite a program to compute average quiz scores for a course- The cours.pdf
Cargando en ... 3
1 de 2
Publicidad

Más contenido relacionado

Similar a Write a C++ program to compute numeric grades for a course- The course.docx(20)

Más de lez31palka(20)

Publicidad

Write a C++ program to compute numeric grades for a course- The course.docx

  1. Write a C++ program to compute numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the fol- lowing format: each line contains a student’s last name, then one space, the the student’s first name, then one space, then ten quiz scores all on one line The quiz scores are whole numbers and are separated by one space. Your program will take its input from this file and send its output to a second file. The data in the output file will be the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student’s ten quiz scores. If this is being done as a class assignment, obtain the file names from your instructor. use at least one function that has file streams as all or some of its arguments. use the file "6_02_in" in the general section of Moodle. The file could include more data with the same format. Use 6_02_out for output file name. Solution #include <iostream> #include <fstream> #include <string> using namespace std; int main(){ ifstream infile; ofstream outfile; string filename; cout<<"Enter input filename"; cin>>filename; infile.open(filename.c_str()); cout<<"Enter output filename"; cin>>filename; outfile.open(filename.c_str()); string firstname,lastname; int grade[10]; double average; int count =0; while(infile>>lastname){
  2. outfile<<lastname<<" "; infile>>firstname; outfile<<firstname<<" "; int sum =0; for(int i=0;i<10;i++){ infile>>grade[i]; sum+=grade[i]; outfile<<grade[i]<<" "; } average = sum/10.0; outfile<<average<<endl; } return 0; }
Publicidad