Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

MTS 3063

PRINSIP PENGATURCARAAN

ASSIGNMENT
(GROUP PROJECT)

GROUP: B

PROVIDED:

NAME MATRIC NO
IZZUDDIN BIN ISHAK D20191088261
BALKIS BINTI ABDULLAH D20191087773
SITI NUR ALLIA BINTI SHAHUDI D20191087895
MOHD LOQMAN BIN TAMMIM D20172080284

LECTURER’S NAME: PUAN SAIRA BANU BINTI OMAR KHAN


1. Complete C++ Program listing with comments.

//This program to provide credit card services to all the


customer who fulfilled the requirements.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

//Array
const int SIZE = 10;
string IC[SIZE];
string name[SIZE];
int salary[SIZE],no_loan[SIZE], loan_payment[SIZE];
int i=0;
string type[SIZE];
char cont;

fstream infile("inputm.txt", ios::in| ios::out);

//function
int personal_info(string, string, int, int, int);
void eligibility_cust();
void menu_company();
void output_file();

//*******************************************************
// Function main *
//*******************************************************

int main ()
{
// for display
cout << "***************************************"<<endl;
cout << "ABC FINANCING COMPANY"<< endl;
cout << " "<<endl;
cout << "List of customers' personal informations"<< endl;
cout << " "<<endl;
personal_info(name[i], IC[i],
salary[i],no_loan[i],loan_payment[i]);
cout << " "<<endl;
eligibility_cust();
cout << " "<<endl;
menu_company();
cout << " "<<endl;
output_file();
cout << " That's all, thank you!";
cout << "\n***************************************";
}

//*******************************************************
// Definition of function personal_info *
// This function displays a data from the input file *
//*******************************************************

int personal_info(string, string, int, int, int)


{
while (!infile.eof()) {
infile >>
IC[i]>>name[i]>>salary[i]>>no_loan[i]>>loan_payment[i];
i++;
}
for (int j=0; j<i; j++){
cout << IC[j]<<" "<<name [j]<<" "<<salary[j]<<"
"<<no_loan[j]<<" "<< loan_payment[j]<<" "<<endl;
}
return IC[i], name[i], salary[i],no_loan[i],
loan_payment[i];
}

//*********************************************************
// Definition of function eligibility_cust *
// This function displays the eligibility of each customer*
//*********************************************************

void eligibility_cust()
{
//Array with the eligibility for each type of cards
string type_of_cards[3]={ "Eligibility for Platinum Card",
"Eligibility for Gold Card", "Eligibility for Silver Card"};

//Array with the names of customers that eligibile for each


type of cards
string customer_eligibility[3]={ "ALI", "AFRINA &
ALI","AFRINA & ALI"};

//Display the eligibility for three type of cards and the


customers who eligibile.
for (int i = 0; i < 3; i++) {
cout << type_of_cards[i] << "\n ";
cout << customer_eligibility[i] << "\n "<<endl;
}
}
//*********************************************************
// Definition of function menu_company *
// This function displays a menu *
//*********************************************************

void menu_company()
{
int choice, salary, loan_payment;
double balance;

cout<<"Do you want to start the system ? [y/n]: ";


cin>>cont;

while(cont == 'y'|| cont == 'Y')


{
cout<< "\nABC FINANCING COMPANY"<<endl;
cout<<"MENU"<<endl;
cout<<"1. Display of PLATINUM card Holder"<<endl;
cout<<"2. Display of GOLD card Holder"<<endl;
cout<<"3. Display of SILVER card Holder"<<endl;
cout<<"4. EXIT"<<endl;
cout<<"\nPlease Enter Your Choice : ";
cin>>choice;

if(salary >= 40000 && loan_payment <= 10000)


{
choice = 1;
}
else if(salary >= 15000 && loan_payment <= 2000)
{
choice = 2;
}
else if(salary >= 5000 && loan_payment <= 1000)
{
choice = 3;
}

fstream infile("inputm.txt", ios::in);

if(choice == 1)
{
cout<<"\n Nickname "<<" IC Number "<<" Balance from
salary "<<endl;
cout<<" Ali "<<" 851207-02-7762 "<<" RM30000 \n"<<endl;
}
else if (choice == 2)
{
cout<<"\n Nickname "<<" IC Number "<<" Balance from
salary "<<endl;
cout<<" Ali "<<" 851207-02-7762 "<<" RM30000 "<<endl;
cout<<" Afrina "<<" 851205-07-6734 "<<" RM15000
\n"<<endl;

}
else if (choice == 3)
{
cout<<"\n Nickname "<<" IC Number "<<" Balance from
salary "<<endl;
cout<<" Ali "<<" 851207-02-7762 "<<" RM30000 "<<endl;
cout<<" Afrina "<<" 851205-07-6734 "<<" RM15000
\n"<<endl;
}
else if (choice == 4)
{
cout<<"\n EXIT \n"<<endl;
}

cout<<" Do you want to continue ? [y/n]: ";


cin>>cont;
}
}

//*********************************************************
// Definition of function output_file *
// This function is to store information *
//*********************************************************

void output_file()
{
fstream outfile;
outfile.open("outputm.txt", ios::out);
if (!outfile) {
cout << "File not created!";
}
else {
cout << "File created successfully!";
for (int i = 0; i<10; i++){
outfile <<left<<" "<< IC[i] <<left <<" "<<
type[i]<<endl;
}

outfile.close();
}
}
2. Input and output file.
Input file (inputm.txt)
851205-07-6734 AFRINA 17000 1 2000
851207-02-7762 ALI 40000 1 10000
801112-02-3421 SYAKILA 4000 1 1000
Output file (outputm.txt)
851205-07-6734 G
851207-02-7762 P
801112-02-3421 N
851205-07-6734 S
851207-02-7762 S
851207-02-7762 G
3. Example of output. (use print screen)

You might also like