Problem 168

A Little Database is Shorter with a Loop

Make a class to store information about a student, which should handle a name, a grade classification, and an average.

Create an array of type Student with three slots. Read in values for the three students and print them out again.

You must use a for loop.

Enter the first student's name: Esteban
Enter the first student's grade: 12
Enter the first student's average: 79.3

Enter the second student's name: Dave
Enter the second student's grade: 10
Enter the second student's average: 91

Enter the third student's name: Michelle
Enter the third student's grade: 11
Enter the third student's average: 98.6

The names are: Esteban Dave Michelle
The grades are: 12 10 11
The averages are: 79.3 91 98.6

The average for the three students is: 89.633333

◄ 167: A Little Database 169: Getting Data from a File ►



Adapted from ProgrammingByDoing.com
©2013 Graham Mitchell

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.