Filename: cs201hw2b.cpp Using this program as a guide http://students.cmps.subr.
ID: 3558854 • Letter: F
Question
Filename: cs201hw2b.cpp Using this program as a guide http://students.cmps.subr.edu/cs190/class_examples/ex-structure.cpp Write a program that creates a structure that will store a student's name, ID number, age, and 3 test scores. Each line will contain a students id, age and 3 test scores. Print out the students id, age, 3 test scores and total number of points. Your program should work for any number of lines of data. Example Data File Smith 124 25 100 90 80 Jones 400 18 90 80 70 Gray 455 20 60 77 71
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
struct student_info
{
string name;
int ID;
int age;
int test[3];
};
student_info student;
main()
{
while (cin>>student.name>>student.ID>>student.age >> student.test[0] >> student.test[1] >> student.test[2])
{
cout <<student.ID << " " << student.age << " " <<student.test[0] <<" " << student.test[1] << " " <<student.test[2] << " " <<
(student.test[0] + student.test[1] + student.test[2]) << endl;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.