Вы находитесь на странице: 1из 12

TUNKU ABDUL RAHMAN COLLEGE SCHOOL OF ART AND SCIENCE

Microelectronic with Computer Communication AACS1513: INTRODUCTION TO PROGRAMMING


ASSIGNMENT 1 DESIGN AND DEVELOP A PAYROLL PROGRAM
STUDENT NAME IC NO. STUDENT ID PROGRAMME TUTORIAL GROUP TUTOR NAME : CHIANG CHOON YONG : 931231-08-5247 : 11WAD05854 : INTRODUCTION TO PROGRAMMING : DMI1 (J1) : MR SHOONG WAI KIN

Page 1

Table of Content
Contents
1. 2. 3. 4. Constants Variables Program Outputs/ Screenshots Program Listing/ Source code

Page
3 4-5 6-8 9-11

Page 2

Constants
Constant a b c d e Description A fixed value that show the price of Set Lunch A in Rich Express Cafe. A fixed value that show the price of Set Lunch B in Rich Express Cafe. A fixed value that show the price of Sandwich in Rich Express Cafe. A fixed value that show the price of Soft Drink in Rich Express Cafe. A fixed value that show the price of Mineral Water in Rich Express Cafe. Data type Double Double Double Double Double Value 7.50 8.00 3.00 2.00 1.50

Page 3

Variables
Variable Type Input Variable Name id date month year d1 Description To store the value of Cashier ID that will display on the receipt. To store the value of date that will display on the receipt. To store the value of month that will display on the receipt. To store the value of year that will display on the receipt. To store the value of the percentage of discount that will display on the receipt. To store the value of quantity of Set Lunch A that order by the customer. This value will be used to calculate the amount1 and also the g_total1. To store the value of quantity of Set Lunch B that order by the customer. This value will be used to calculate the amount2 and also the g_total1. To store the value of quantity of Sandwich that order by the customer. This value will be used to calculate the amount3 and also the g_total1. To store the value of quantity of Soft Drink that order by the customer. This value will be used to calculate the amount4 and also the g_total1. To store the value of quantity of Mineral Water that order by the customer. This value will be used to calculate the amount5 and also the g_total1. To store the character that input by the user. It will be identify later to check the customer status. To store the value that calculate from the value f. To store the value that calculate from the value g. Data type int int int int int

int

int

int

int

int

status

char

Intermediate amount1 process amount2

double double

Page 4

amount3 amount4 amount5 g_total1 g_total2

Output

charge

tax

discount

total_pay

To store the value that calculate from the value h. To store the value that calculate from the value i. To store the value that calculate from the value j. To store the value of total amount of f, g, h, i, j that input by the user. To store the value of total amount that calculates from the sum of amount1, amount2, amount3, amount4, amount5. It is used to aid the calculation of charge, tax, discount, and total_pay later. To store the value that calculates by using the value of g_total2 and this value will use later to calculate the total_pay. To store the value that calculates by using the value of g_total2 and this value will use later to calculate the total_pay. To store the value that calculates by using the value of g_total2 and this value will use later to calculate the total_pay. To store the value of total amount. total_pay = g_total2 + charge + tax + (-discount).

double double double int double

double

double

double

double

Page 5

Screenshots
First Output With the member status of GOLD.

Page 6

Second Output With the member status of PLATINUM.

Page 7

Third Output With the non-member status.

Page 8

Fourth Output Input the quantity with only single digit.

Page 9

Source Code
/********************************************************************** ****************** Name : Chiang Choon Yong IC number : 931231-08-5247 Student ID : 11WAD05854 Project : Design and develop Payroll Program that calculate net pay of a salesperson. *********************************************************************** *****************/ #include <iostream> #include <iomanip> using namespace std; main() { const double a = 7.50, b = 8.00, c = 3.00, d = 2.00, e = 1.50; int id, date, month, year, d1; int f, g, h, i, j; char status; double g_total1, g_total2, charge, tax, discount, total_pay; double amount1, amount2, amount3, amount4, amount5; cout<<" Enter the Date : "; cin>>date; cout<<" Enter the Month : "; cin>>month; cout<<" Enter the Year : "; cin>>year; cout<<" Enter cin>>f; cout<<" Enter cin>>g; cout<<" Enter cin>>h; cout<<" Enter cin>>i; cout<<" Enter cin>>j; cout<<endl; the quantity of Set Lunch A : "; the quantity of Set Lunch B : "; the quantity of Sandwich : "; the quantity of Soft Drink : "; the quantity of Mineral water : ";

cout<<" Enter the Cashier ID : "; cin>>id; cout<<" Enter the Member Status : "; cin>>status;

Page 10

amount1 = f * a; // quantity the price of Set Lunch A. amount2 = g * b; // quantity the price of Set Lunch B. amount3 = h * c; // quantity price of Sandwich. amount4 = i * d; // quantity price of Soft Drink. amount5 = j * e; // quantity the price of Mineral Water.

of Set Lunch A multiple with a which is of Set Lunch B multiple with b which is of Sandwich multiple with c which is the of Soft Drink multiple with d which is the of Mineral Water multiple e which is with

g_total1 = f + g + h + i + j; // Sum of all the quantity that input by user. g_total2 = amount1 + amount2 + amount3 + amount4 + amount5; // Sum of the amount1, amount2, amount3, amount4 and amount5. charge = 0.1 * g_total2; // charge is the 10% of the g_total2. tax = 0.06 * g_total2; // tax is the 6% of the g_total2. cout<<endl; cout<<endl; cout<<"RRRRRRRRRRR cout<<"RRRRRRRRRRRR cout<<"RRRR RRRR cout<<"RRRR RRRR cout<<"RRRR RRRR cout<<"RRRRRRRRRRRR cout<<"RRRRRRRRRRR cout<<"RRRRRRRRRR cout<<"RRRR RRRR cout<<"RRRR RRRR cout<<"RRRR RRRR cout<<endl; cout<<endl; cout<<endl; IIIIIIIIIII IIIIIIIIIII IIIII IIIII IIIII IIIII IIIII IIIII IIIII IIIIIIIIIII IIIIIIIIIII CCCCCCCCCC CCCCCCCCCC CCCCCCC CCCCCC CCCC CCC CCCC CCCCC CCCCCCC CCCCCCCCCC CCCCCCCCCC HHH HHH\n"; HHH HHH\n"; HHH HHH\n"; HHH HHH\n"; HHHHHHHHHH\n"; HHHHHHHHHH\n"; HHHHHHHHHH\n"; HHH HHH\n"; HHH HHH\n"; HHH HHH\n"; HHH HHH\n";

cout<<" ~~~ RICH EXPRESS Cafe ~~~ "<<endl<<endl; cout<<" RECEIPT "<<endl; cout<<"Cashier ID : "<<id<<"\t\t Date : "<<setw(2)<<setfill('0')<<date<<"/"<<setw(2)<<month<<"/"<<setw(4)<<year <<endl; cout<<setfill(' '); if ( status == 'x' || status == 'X' ) { discount = (-0.05) * g_total2; d1 = 5; cout<<"Member : Gold"; } else if ( status == 'y' || status == 'Y') { discount = (-0.10) * g_total2;

Page 11

d1 = 10; cout<<"Member } else {

: Platinum";

discount = (-0.00) * g_total2; d1 = 0; cout<<"Member : N/A"; } total_pay = g_total2 + tax + charge + discount; cout<<endl; cout<<"+"<<setw(55)<<setfill('-')<<"+"<<setfill(' ')<<endl; cout<<"| Item Description | Quantity | Amount (RM) |"<<endl; cout<<"+"<<setw(55)<<setfill('-')<<"+"<<setfill(' ')<<endl; cout<<"| Set Lunch A | "<<left<<setw(6)<<f<<" |"<<right<<setw(11)<<fixed<<setprecision(2)<<amount1<<" |"<<endl; cout<<"| Set Lunch B | "<<left<<setw(6)<<g<<" |"<<right<<setw(11)<<setprecision(2)<<amount2<<" |"<<endl; cout<<"| Sandwich | "<<left<<setw(6)<<h<<" |"<<right<<setw(11)<<setprecision(2)<<amount3<<" |"<<endl; cout<<"| Soft Drink | "<<left<<setw(6)<<i<<" |"<<right<<setw(11)<<setprecision(2)<<amount4<<" |"<<endl; cout<<"| Mineral Water | "<<left<<setw(6)<<j<<" |"<<right<<setw(11)<<setprecision(2)<<amount5<<" |"<<endl; cout<<"+"<<setw(55)<<setfill('-')<<"+"<<setfill(' ')<<endl; cout.unsetf(ios::fixed); cout<<"| Gross Total |"<<setw(6)<<g_total1<<" |"<<setw(11)<<fixed<<setprecision(2)<<g_total2<<" |"<<endl; cout<<"+"<<setw(55)<<setfill('-')<<"+"<<setfill(' ')<<endl; cout<<"| Charges : | |"<<endl; cout<<"| Service Charge (10%) |"<<setw(11)<<setprecision(2)<<charge<<" |"<<endl; cout<<"| Goverment Tax (06%) |"<<setw(11)<<setprecision(2)<<tax<<" |"<<endl; cout<<"+"<<setw(55)<<setfill('-')<<"+"<<setfill(' ')<<endl; cout<<"| Discount : ("<<setw(2)<<setfill('0')<<d1<<"%"<<") |"<<setfill(' ')<<setw(11)<<setprecision(2)<<discount<<" |"<<endl; cout<<"+"<<setw(55)<<setfill('-')<<"+"<<setfill(' ')<<endl; cout<<" Net Pay |"<<setfill('*')<<setw(11)<<setprecision(2)<<total_pay<<" |"<<endl; cout<<setw(38)<<setfill(' ')<<"+"<<setw(18)<<setfill('-')<<"+"<<endl; cout<<"\t THANK YOU and HAVE A NICE DAY .\n"; return 0; }

Page 12

Вам также может понравиться