Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
program that creates student class and object and calculate the student courses payments.
  • Loading branch information
eyalbi authored May 30, 2020
0 parents commit 9a19ebb
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Student class/Header.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include <iostream>
#include "student.h"
#include <string>
#define ZERO 0


Student::Student(char * name, long id, int courseNum, int milga)
{
Set_Name (name);
Set_Id (id);
Set_CourseNum (courseNum);
Set_Scolar(milga);
}

Student::Student(const Student & obj)
{
strcpy_s(FName, 51, obj.FName);
Set_Id(obj.Id);
Set_CourseNum(obj.CourseNum);
Set_Scolar(obj.ScolarShip);
}

void Student::Set_Name(char * name)
{
strcpy_s(FName,51, name);

}

void Student::Set_Id(long id)
{
Id = id;
}

void Student::Set_CourseNum(int num)
{
if (num > ZERO) {
CourseNum = num;
}
else {
CourseNum = ZERO;
}
}

void Student::Set_Scolar(int milga)
{

if (milga < ZERO) {
ScolarShip = ZERO;
}
else {
ScolarShip = milga;
}
}

int Student::StudentFees()
{
if ((CourseNum * 1500) - ScolarShip > ZERO) {
return (CourseNum * 1500) - ScolarShip;
}
else
{
return ZERO;
}
}

void Student::PrintSData()
{
cout << "student name: " << FName << ", ID: " << Id << ", NO. of Courses: " << CourseNum << "\nscolarship:" << ScolarShip << ", Tuition fees: " << StudentFees() << endl;
}
38 changes: 38 additions & 0 deletions Student class/ex1_dec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include "student.h"
#include <string>
using namespace std;
int main() { // äâãøú ùðé àåáéé÷èéí îèéôåñ ñèåãðè àéúçåìí åçéùåá ùëø ìéîåãí
char TName[51];
long TId;
int TMilga, TCourseNum;
cout << "enter student name" << endl;
cin.getline(TName, 51);
cout << "enter student ID" << endl;
cin >> TId;
cout << "enter the student's number of courses" << endl;
cin >> TCourseNum;
cout << "enter scolarship fees" << endl;
cin >> TMilga;
Student S1(TName, TId, TCourseNum, TMilga);
S1.PrintSData();
getchar();
cout << "enter student name" << endl;
cin.getline(TName, 51);
cout << "enter student ID" << endl;
cin >> TId;
cout << "enter the student's number of courses" << endl;
cin >> TCourseNum;
cout << "enter scolarship fees" << endl;
cin >> TMilga;
Student S2(TName, TId, TCourseNum, TMilga);
S2.PrintSData();
int U;
cout << "update student 1 num of courses:" << endl;
cin >> U;
S1.Set_CourseNum(U);
S1.PrintSData();

return ZERO;
}

24 changes: 24 additions & 0 deletions Student class/student.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
#include <string>
#define ZERO 0
using namespace std;
class Student{ //äëøæú îçì÷ä
private:
char FName[51]; //ðúåðéú îçì÷ä
long Id;
int CourseNum;
int ScolarShip;
public:
Student(char *, long, int, int); // áðàé äî÷áì ôøîèøéí åîàúçì àú ðúåðé äîçì÷ä
Student(const Student & obj); // áðàé îòúé÷
char* Get_Name() { return FName; } //ôåð÷öéåú ì÷áìú ðúåðé äîçì÷ä
long Get_Id() { return Id; }
int Get_CourseNum() { return CourseNum; }
int Get_Scolar() { return ScolarShip; }
void Set_Name(char *); // ôåð÷öéåú ìòøéëú ðúåðé äîçì÷ä
void Set_Id(long);
void Set_CourseNum(int);
void Set_Scolar(int);
int StudentFees(); //ôåð÷öééä ìçéùåá ùëø ìéîåã ùì úìîéã
void PrintSData(); //ôåð÷öéä ìäãôñú ðúåðé úìîéã
};

0 comments on commit 9a19ebb

Please sign in to comment.