You are on page 1of 17

MTS3063

PROGRAMMING PRINCIPLES

GROUP PROJECT

PROGRAMME
NAME MATRIC NUMBER
CODE

AINA NAJWA BINTI RAZALI D20221102557 AT20

NUR RIF’AH BINTI RIZAL D20221102554 AT20

NURUL AINA AFRIENA BINTI MOHD IDRIS D20221102564 AT20

PUTRI NUR ASIAH BINTI BAHRIN D20221102551 AT20

NUR HAZIQAH BINTI MOHD.HUZAIRI D20221102552 AT20

LECTURER:
PUAN SAIRA BANU BINTI OMAR KHAN

TARIKH
1 FEBUARY 2023

1
CONTENTS

NO CONTENTS PAGE

1 Contents 2

2 Problem Analysis 3

3 Completed coding with comments 5

4 Example of input and output 9

5 File input 12

6 Attachment 13

2
PROBLEM ANALYSIS
1) Main input
Program read data file named application.dat. In application.dat read name, IC number,
salary, number of loan and monthly loan payment. User should enter choice based on
main menu displayed depends on what they need.

2) Menu
The input is in the form of number 1 until number 6. The output for each number was
different. If user key in:
1. Option 1 is for user to know the file was already read or not.
2. Option 2 is for user to know the details of customer that eligible to get the platinum
card.
INPUT 3. Option 3 is for user to know the details of customer that eligible to get the gold
card.
4. Option 4 is for user to know the details of customer that eligible to get the silver
card.
5. Option 5 is for user to know the details of customer that noneligible to get any
types of card.
6. Option 6 is for user to exit the system.

3) Input new data


When there is added customer, their new input should key in in file named
application.dat.

1) If user choose ‘1’, the program will read name, IC number, salary, number of loan
and monthly payment loan in file named application.dat. The programme will call the
function application from customer.

2) Then if user choose ‘2’ information of platinum card holder will display based on
requirement for credit card application. The programme will call function platinum. For
platinum card holder, minimum monthly salary is RM 20,000 and only has one financing
loan which the amount is less than 25% from the monthly salary.

PROCESS
3) After that, if user choose ‘3’ information of gold card holder will display based on
requirement for credit card application. The programme will call function gold. For gold
card holder, minimum monthly salary is RM 10,000 and only has one financing loan
which the amount is less than 25% from the monthly salary.

4) Next, if user choose ‘4’ information of silver card holder will display based on
requirement for credit card application. The programme will call function silver. For
silver card holder, minimum monthly salary is RM 3,000 and only has one financing loan
which the amount is less than 25% from the monthly salary.

3
5) Other than that, if user choose ‘5’ the information of noneligible customer will
display. The programme will call function nonEligible. For noneligible customer, they
don’t deserve any of card holder because of the minimum monthly salary is less than RM
3,000 and they have more than one financing loan which the amount is more than
25% from the monthly salary.

OUTPUT Display “Your file has been read “ OR name, IC number, salary, number of loan,
monthly loan payment, p OR “THANK YOU“.

4
COMPLETED CODING WITH COMMENTS

5
6
7
8
EXAMPLES OF INPUT AND OUTPUT

The output if user input number 1 :

The output if user input number 2 :

9
The output if user input number 3 :

The output if user input number 4 :

1
The output if user input number 5 :

The output if user input number 6 :

1
FILE INPUT

File input that have all customers information is in file name application.dat .

1
ATTACHMENT

Full coding:
1 /*AINA NAJWA BINTI RAZALI D20221102557
2 NURUL AINA AFRIENA BINTI MOHD IDRIS D20221102564
3 PUTRI NUR ASIAH BINTI BAHRIN D20221102551
4 NUR RIF’AH BINTI RIZAL D20221102554
5 NUR HAZIQAH BINTI MOHD.HUZAIRI D20221102552*/
6
7
8 #include<iostream> //input and output involved
9 #include<fstream> //file involved
10
11 using namespace std;
12 const int SIZE=100;//size declaration
13
14 //function prototype
15 int input(string [],string [], double [],int [], double []);//function
prototype for input
16 void platinum(string [],string [], double [],int [], double
[]);//function prototype for platinum
17 void gold(string [],string [], double [],int [], double []);//function
prototype for gold
18 void silver(string [],string [], double [],int [], double
[]);//function prototype for silver
19 void nonEligible(string [],string [], double [],int [], double
[]);//function prototype for non-eligible
20
21 void main()//main function
22 {
23 string name[SIZE];//declare variable name for array
24 string IC_NO[SIZE];//declare variable ic for array
25 double salary[SIZE];//declare variable salary for array
26 int no_of_loan[SIZE]; //declare variable number of loan for array
27 double loan[SIZE];//declare variable monthly loan payment for array
28 int choice;//declare variable
29 char either;//declare variable
30
31 do //do while loop
32 {
33 system("cls");//clear screen
34 cout<<endl << "\t ONE STOP FINANCING COMPANY"<<endl<<endl;//print
message for menu
35 cout<< "\t1. Application from customers"<< endl;//print massage for
menu
36 cout<< "\t2. Display of PLATINUM card Holder"<< endl;//print massage
for menu
37 cout<< "\t3. Display of GOLD card Holder"<< endl;//print massage for
menu
38 cout<< "\t4. Display of SILVER card Holder"<< endl;//print massage for
menu
39 cout<< "\t5. Display non eligible application"<< endl;//print massage
for menu
40 cout<< "\t6. EXIT"<< endl<<endl;//print massage for menu
41 cout<<"\tPlease enter your choice : ";//print message to get onput
from user
42 cin>>choice;//input choice from user
43
44 switch (choice)//switch statement

1
45 {
46 case 1:
47 input(name, IC_NO, salary, no_of_loan, loan); //call function input
48 break;
49
50 case 2:
51 platinum(name, IC_NO, salary, no_of_loan, loan); //call function
platinum
52 break;
53
54 case 3:
55 gold(name, IC_NO, salary, no_of_loan, loan); //call function gold
56
57 break;
58
59 case 4:
60 silver(name, IC_NO, salary, no_of_loan, loan); //call function
silver
61 break;
62
63 case 5:
64 nonEligible(name, IC_NO, salary, no_of_loan, loan); //call function
noneligible
65 break;
66
67 case 6:
68 cout<<endl<<"\t\t THANK YOU :)"<<endl; //exit
69 break;
70
71 default:
72 break;
73 }
74 cin.ignore();
75 cin.get();
76
77 }
78 while(choice != 6) ;
79 }
80
81 //function application from customer
82 int input(string name[], string IC_NO[], double salary[],int
no_of_loan[], double loan[])
83 {
84 int i=0;//variable counter
85 cout<< endl <<" \t APPLICATION FROM CUSTOMER ";//print message
86 cout<< endl <<" \t -------------------------- "<<endl;//print message
87
88 ifstream myFile("application.dat"); //read input from
(application.dat) file
89 while (!myFile.eof())//read all input from file line by line
90 {
91 getline(myFile,name[i]);//store name in array
92 myFile >> IC_NO[i] >> salary[i] >> no_of_loan[i] >>
loan[i];//store ic, salary,number of loan and loan in array
93 i++;//increment the loop counter
94 }
95 cout<<"\t Your file has been read"<<endl;//print message
96 return 0;
97 }
98
99 //function platinum card holder

1
100 void platinum(string name[], string IC_NO[], double salary[],int
no_of_loan[], double loan[])
101 {
102 int i=0;//variable counter
103 cout<< endl <<" \t PLATINUM CARD HOLDER ";//print message
104 cout<< endl <<" \t -------------------- "<<endl<<endl;//print message
105
106 ifstream myFile ("application.dat"); //read input from
(application.dat) file
107 while (!myFile.eof())//read all input from file line by line
108 {
109 getline(myFile, name[i]);//store name in array
110 myFile >> IC_NO[i] >> salary[i] >> no_of_loan[i] >> loan[i];//store
ic, salary,number of loan and loan in array
111 i++;//increment the loop counter
112 }
113 int p=0;//variable counter
114 for (int k=0; k<i; k++)//for statement
115 {
116 if(salary[k]>20000 && no_of_loan[k]==1 && loan[k]<0.25*salary[k])
//condition for platinum card holder
117 {
118 cout <<" "<< name[k] <<" " << IC_NO[k]<< " " << salary[k] << " "
<< no_of_loan[k] << " " << loan[k] << endl;
119 //display name, ic, salary, number of loan and monthly payment
loan
120 p=p+1;//increment the loop counter
121 }
122 }
123 cout <<endl <<"\n Number of platinum card holder : " << p << endl;
//display number of platinum card holder
124 myFile.close();//close file
125 cout<<endl;//new line
126 }
127
128 //function gold card holder
129 void gold(string name[], string IC_NO[], double salary[],int
no_of_loan[], double loan[])
130 {
131 int i=0;//variable counter
132 cout<< endl <<" \t GOLD CARD HOLDER ";//print message
133 cout<< endl <<" \t ---------------- "<<endl<<endl;//print message
134
135 ifstream myFile ("application.dat");//read input from
(application.dat) file
136 while (!myFile.eof())//read all input from file line by line
137 {
138 getline(myFile, name[i]);//store name in array
139 myFile >> IC_NO[i] >> salary[i] >> no_of_loan[i] >> loan[i];//store
ic, salary,number of loan and loan in array
140 i++;//increment the loop counter
141 }
142 int g=0;//variable counter
143 for (int k=0; k<i ; k++)//for statement
144 {
145 if(salary[k]>=10000 && salary[k]<20000 && no_of_loan[k]==1 &&
loan[k]<0.25*salary[k])//condition for gold card holder
146 {
147 cout <<" "<< name[k] << " " << IC_NO[k]<< " " << salary[k] << "
" << no_of_loan[k] << " " << loan[k] << endl;
148 //display name, ic, salary, number of loan and monthly payment

1
loan
149 g=g+1;//increment the loop counter
150
151 }
152 }
153 cout <<endl <<"\n Number of gold card holder : " << g <<
endl;//display number of gold card holder
154 myFile.close();//close file
155 cout<<endl;//new line
156 }
157
158 //function silver card holder
159 void silver(string name[], string IC_NO[], double salary[],int
no_of_loan[], double loan[])
160 {
161 int i=0;//variable counter
162 cout<< endl <<" \t SILVER CARD HOLDER ";//print message
163 cout<< endl <<" \t ------------------ "<<endl<<endl;//print message
164
165 ifstream myFile ("application.dat");//read input from
(application.dat) file
166 while (!myFile.eof())//read all input from file line by line
167 {
168 getline(myFile, name[i]);//store name in array
169 myFile >> IC_NO[i] >> salary[i] >> no_of_loan[i] >> loan[i];//store
ic, salary,number of loan and loan in array
170 i++;//increment the loop counter
171 }
172 int s=0;//variable counter
173 for (int k=0; k<i ; k++)//for statement
174 {
175 if(salary[k]>+3000 && salary[k]<10000 && no_of_loan[k]==1 &&
loan[k]<0.25*salary[k]) //condition for silver card holder
176 {
177 cout <<" "<< name[k] << " " << IC_NO[k]<< " " << salary[k] << "
" << no_of_loan[k] << " " << loan[k] << endl;
178 //store ic, salary,number of loan and loan in array
179 s=s+1;//increment the loop counter
180 }
181 }
182 cout <<endl <<"\n Number of silver card holder : " << s <<
endl;//display number of silver card holder
183 myFile.close();//close file
184 cout<<endl;//new line
185 }
186
187 //function non-eligible customer
188 void nonEligible(string name[], string IC_NO[], double salary[],int
no_of_loan[], double loan[])
189 {
190 int i=0;//variable counter
191 cout<< endl <<" \t NON ELIGIBLE APPLICATION ";//print message
192 cout<< endl <<" \t ------------------------- "<<endl<<endl;//print
message
193
194
195 ifstream myFile ("application.dat");//read input from
(application.dat) file
196 while (!myFile.eof())//read all input from file line by line
197 {
198 getline(myFile, name[i]);//store name in array

1
199 myFile >> IC_NO[i] >> salary[i] >> no_of_loan[i] >> loan[i];
200 //store ic, salary,number of loan and loan in array
201 i++;//increment the loop counter
202 }
203 int n=0;//variable counter
204 for (int k=0; k<i; k++)//for statement
205 {
206 if (salary[k]<3000 || no_of_loan[k]!=1 ||
loan[k]>0.25*salary[k])//condition for non-eligible card holder
207 {
208 cout <<" "<< name[k] << " " << IC_NO[k]<< " " << salary[k] << "
" << no_of_loan[k] << " " << loan[k] << endl;
209 //store ic, salary,number of loan and loan in array
210 n=n+1;//increment the loop counter
211 }
212 }
213 cout <<endl <<"\n Number of non eligible application : " << n <<
endl;//display number of non eligible application
214 myFile.close();//close file
215 cout<<endl;//new line
216 }

Customer details in file application.dat:

1 Muhammad Ali bin Musa


2 780210025623 12000 1 567 Rasmina binti Halis
3 801207073982 21000 1 789 Salmah binti Saad
4 020202043378 3840.70 1 777 Aina Najwa Binti Razali
5 020905024584 25300 3 2000 Nur Haziqah binti Huzairi
6 001245863582 11520 1 978 Putri Asiah binti Bahrin
7 981012563459 30890 1 6700 Aina Afriena binti Idris
8 030220104586 5420 1 900 Nur Rifah binti Rizal
9 020913102368 17000 1 5900 Abu Bakar bin Ahmad
10 658123456897 20110 1 900 Melati binti Omar
11 875412510220 5000 1 430 Melur binti Zulkarnain
12 735215546252 1200 1 90 Erick Suvatti A/L Palakuru
13 895468213100 4560 2 2000 Azri bin Tweppih
14 020145332777 18000 1 500 Azim bin Twenggah
15 020512533833 11300 1 2010 Wo Pu Tong
16 658976514444 13750 1 875.90

You might also like