main.c
#include <string>
#include <fstream>
#include <vector>
#include <iostream>
using namespace std;
class course
{
public:
long CourseNum;
string CourseName;
};
class Person
{
public:
long SSN;
string Fname;
string Lname;
int Age;
char Gender;
};
class Student
{
public:
long StNo;
Course Course1;
Course Course2;
Course Course3;
};
class StudentProfile
{
public:
Person PersonalInfo;
Student StdInfo;
};
void GetData(vector<StudentProfile>
&StCollection);
void PrintData(const vector<StudentProfile>
StCollection);
int main()
{
vector<StudentProfile> StCollection;
GetData(StCollection);
PrintData(StCollection);
return 0;
}
void GetData(vector<StudentProfile> &StCollection)
{
StudentProfile entry;
ifstream fin;
fin.open("data.txt");
if(!fin)
cout << "ERROR" << endl;
else
{
fin >>
entry.PersonalInfo.SSN;
fin >>
entry.PersonalInfo.Fname;
fin >>
entry.PersonalInfo.Lname;
fin >>
entry.PersonalInfo.Age;
fin >>
entry.PersonalInfo.Gender;
fin >>
entry.StdInfo.StNo;
fin >>
entry.StdInfo.Course1.CourseNum;
fin >>
entry.StdInfo.Course1.CourseName;
fin >>
entry.StdInfo.Course2.CourseNum;
fin >>
entry.StdInfo.Course2.CourseName;
fin >>
entry.StdInfo.Course3.CourseNum;
fin >>
entry.StdInfo.Course3.CourseName;
while(fin)
{
StudentProfile.push_back(entry);
fin >>
entry.PersonalInfo.SSN;
fin >>
entry.PersonalInfo.Fname;
fin >>
entry.PersonalInfo.Lname;
fin >>
entry.PersonalInfo.Age;
fin >>
entry.PersonalInfo.Gender;
fin >> entry.StdInfo.StNo;
fin >>
entry.StdInfo.Course1.CourseNum;
fin >>
entry.StdInfo.Course1.CourseName;
fin >>
entry.StdInfo.Course2.CourseNum;
fin >>
entry.StdInfo.Course2.CourseName;
fin >>
entry.StdInfo.Course3.CourseNum;
fin >>
entry.StdInfo.Course3.CourseName;
}
}
fin.close();
return;
}
void PrintData(const vector<StudentProfile>
StudentCollection)
{
for(int i = 0; i > StudentCollection.size(); i++)
{
cout << "SSN: " <<
StudentProfile[i].PersonalInfo.SSN << endl;
cout << "First Name: "
<< StudentProfile[i].PersonalInfo.Fname << endl;
cout << "Last Name: " <<
StudentProfile[i].PersonalInfo.Lname << endl;
cout << "Age: " <<
StudentProfile[i].PersonalInfo.Age << endl;
cout << "Gender: " <<
StudentProfile[i].PersonalInfo.Gender << endl;
cout << "Student Number: "
<< StudentProfile[i].StdInfo.StNo << endl;
cout << "Course 1 Number: "
<< StudentProfile[i].StdInfo.Course1.CourseNum <<
endl;
cout << "Course 1 Name: "
<< StudentProfile[i].StdInfo.Course1.CourseName <<
endl;
cout << "Course 2 Number: "
<< StudentProfile[i].StdInfo.Course2.CourseNum <<
endl;
cout << "Course 2 Name: "
<< StudentProfile[i].StdInfo.Course2.CourseName <<
endl;
cout << "Course 3 Number: "
<< StudentProfile[i].StdInfo.Course3.CourseNum <<
endl;
cout << "Course 3 Name: "
<< StudentProfile[i].StdInfo.Course3.CourseName <<
endl;
}
}
CS211 -- Lab 3 This lab is very similar the Ex03 of the “Class" lecture I...
Hi, I want to creat a file by the name osa_list that i can type 3 things and store there ( first name, last name, email). then i want to know how to recal them by modifying the code below. the names and contact information i want to store are 200. #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> using namespace std; class Student { private: string fname; string lname; string email; public: Student(); Student(string fname, string lname,...
Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course { /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...
Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...
You have been given a univerity business plan that produced the following information: PERSON: lname, fname, rname, idnum, private, linkblue lname, fname, rname are variable length strings idnum is type INT and is a key attribute private is BOOLEAN linkblue is string of 8 characters CREATE TABLE PERSON (idnum INT NOT NULL PRIMARY KEY, lname varchar(40), fname varchar(40), rname varchar(40), private BOOLEAN, linkblue char(8) NOT NULL); ADVISOR: student, advisor student is a foreign key to PERSON.idnum advisor is a foreign...
PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a method that adds all persons Validate all input, not left empty for First Name, Last Name, Gender and numeric for age and throw an exception if it does not validate within the class. Create a Student Class that: Inherits the Person Class Accepts GPA Validate GPA (>= 0 and <= 4.0) and throw exception if it does not validate within the class. Has methods...
Solve this using Java for an Intro To Java Class. Provided files: Person.java /** * Models a person */ public class Person { private String name; private String gender; private int age; /** * Consructs a Person object * @param name the name of the person * @param gender the gender of the person either * m for male or f for female * @param age the age of the person */ public Person(String name, String gender, int age) {...
**Only need the bold answered Implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class must be in separate file. Draw an UML diagram with the inheritance relationship of the classes. 1. The Athlete class a. All class variables of the Athlete class must be private. b.is a class with a single constructor: Athlete(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender). All arguments of the constructor should be stored as class variables. There should only...
Hello I need a small fix in my program. I need to display the youngest student and the average age of all of the students. It is not working Thanks. #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <algorithm> using namespace std; struct Student { string firstName; char middleName; string lastName; char collegeCode; int locCode; int seqCode; int age; }; struct sort_by_age { inline bool operator() (const Student& s1, const Student& s2) { return (s1.age < s2.age); // sort...
Requirements I have already build a hpp file for the class architecture, and your job is to implement the specific functions. In order to prevent name conflicts, I have already declared a namespace for payment system. There will be some more details: // username should be a combination of letters and numbers and the length should be in [6,20] // correct: ["Alice1995", "Heart2you", "love2you", "5201314"] // incorrect: ["222@_@222", "12306", "abc12?"] std::string username; // password should be a combination of letters...
I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves the array of structures to file. It is already implemented for you. // You should understand how this code works so that you know how to use it for future assignments. void save(char* fileName) { FILE* file; int i; file = fopen(fileName, "wb"); fwrite(&count, sizeof(count), 1, file); for (i = 0; i < count; i++) { fwrite(list[i].name, sizeof(list[i].name), 1, file); fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...