/***************************************************************
* Name: Prof. Orta
* Course: Computer Science & Programming
* Class: CS04103 Section: 1 & 2
* Assignment Date: 10/18/20
* File Name: Structs.cpp
*****************************************************************
* ID: Lab 2 Problem 3
* Purpose: Demonstrate the use of structs
*****************************************************************/
#include <iostream>
#include <string>
#include <stdlib.h>
#include <iomanip>
using namespace std;
// Struct definition
struct students
{
int studentID;
string Name;
int section;
string className;
float grade;
};
// Struct instantiation
students rStudents;
// Function Prototype
void dataCollection(students&);
void output(students&);
int main () {
system("clear");
dataCollection(rStudents);
output(rStudents);
}
// Data Collection
void dataCollection(students &rStudent)
{
cout << "Please enter the student id: ";
cin >> rStudents.studentID;
cin.ignore();
cout << "Please enter the student name: ";
getline(cin,rStudents.Name);
cout << "Please enter the class name: ";
getline(cin,rStudents.className);
cout << "Please enter the class section: ";
cin >> rStudents.section;
cout << "Please enter the student grade: ";
cin >> rStudents.grade;
}
// Printing the Student information to the screen.
void output(students &rStudent)
{
system("clear");
cout << "******************************************************************************************" << endl;
cout << left << setw(20) << "Class Name: " << rStudents.className << endl;
cout << left << setw(20) << "Class section: " << rStudents.section << endl;
cout << left << setw(20) << "Student id: " << rStudents.studentID << endl;
cout << left << setw(20) << "Student Name: " << rStudents.Name << endl;
cout << left << setw(20)<< "Student grade: " << rStudents.grade << endl ;
cout << "******************************************************************************************" << endl;
}