-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
program that creates student class and object and calculate the student courses payments.
- Loading branch information
0 parents
commit 9a19ebb
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); //ôåð÷öéä ìäãôñú ðúåðé úìîéã | ||
}; |