Vous êtes sur la page 1sur 7

FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12

ASSIGNMENT 3

Name: ____________________________________________________________________
Student ID: ____________________________________________________________________
Group: ____________________________________________________________________

Submit the answer in ‘GROUP DRAWER’ before 2.00pm (8 Sept 2010 – Wednesday).
All submission answer must in ‘.doc’ file (just put your answer in this document ( assignment
3.doc)). Late submission will be effect your mark.

QUESTION

1 ShareSpace Sdn Bhd offer few categories of virtual spaces via Internet technology to
customer. Customer need to input id, category and year start for subscribe
ShareSpace.Calculate the fees in subscribing the space based on the following formula.

Category Fees
A no fees
B The first 3 years ->RM100 per year
Every year after that -> RM 80 per year
C The first 3 years ->RM150 per year
Every year after that -> RM 110 per year

Print Bill as below: (Sample Output)

******ShareSpace Sdn Bhd******


Id : 1234
Category : B
Subscription Year : 6 Years with the fee : RM 540

ANSWER

Answer 1

# include <iostream.h>
# include <conio.h>
void main()
{
int id;
char char1;
int year;
double fee,total_fee;
FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12
8

cout<<"Id: ";
cin>>id;
cout<<"Category: ";
cin>>char1;

if ( char1 =='A')
{
cout<<"Subscription Year: ";
cin>>year;

total_fee=year*0;
}
else if ( char1 =='B')
{
cout<<"Subscription Year: ";
cin>>year;

fee=3*100;
total_fee=((year-3)*80)+fee;

}
else if( char1 =='C')
{
cout<<"Subscription Year: ";
cin>>year;

fee=3*150;
total_fee=((year-3)*110)+fee;
}
cout<<endl;
cout<<" ******ShareSpace Sdn Bhd****** "<<endl;
cout<<" Id : "<<id<<endl;
cout<<" Category : "<<char1<<endl;
cout<<" Subscription Year : "" "<<year<<" Years with the fee:RM "<<total_fee;

getch();
}

Answer 2

# include <iostream.h>
# include <conio.h>
void main()
{
FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12
8

int id;
char char1;
int year;
double fee,total_fee;

cout<<"******ShareSpace Sdn Bhd****** "<<endl;


cout<<"Id: ";
cin>>id;
cout<<"Category: ";
cin>>char1;

if ( char1 =='A')
{
cout<<"Subscription Year: ";
cin>>year;
total_fee=year*0;
cout<<"Years with the fee:RM "<<total_fee;
}
else if ( char1 =='B')
{

cout<<"Subscription Year: ";


cin>>year;
fee=3*100;
total_fee=((year-3)*80)+fee;
cout<<"Years with the fee:RM "<<total_fee;
}
else if( char1 =='C')
{
cout<<"Subscription Year: ";
cin>>year;
fee=3*150;
total_fee=((year-3)*110)+fee;
cout<<"Years with the fee:RM "<<total_fee;
}

getch();
}
FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12
8

2 DontMind Sdn Bhd offers weekly payment(gross pay) for its employee and the rate as
follow.

Regular rate of rm4.00 per hour for the first 40 hours


1.5 times the regular rate for each hour over 40 through 50 hours.
Double the regular rate for each hour over 50.

From the employee gross pay, the following deduction are made:
8% for income tax deduction
10% for kwsp
RM 10.00 for the employee’s union

Write a program that requires the user to enter the employee’s id and hours worked per
week. Calculate the gross pay, deduction and net pay for employee.

ANSWER

# include <iostream.h>
# include <conio.h>
void main( )
{
int id;
int hour;
double incomeTax,kwsp,gross_pay;
double employee_union,net_pay;

cout<<"Employee's id : ";
cin>>id;

cout<<"Hours worked per week : ";


cin>>hour;

if ( hour<=40)
{
gross_pay=hour*4.00;
incomeTax=0.08*gross_pay;
kwsp=0.10*gross_pay;
FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12
8

employee_union=10;
net_pay=gross_pay - (incomeTax + kwsp + employee_union);
}
else if ( hour>=41)
{
gross_pay=hour*(4.00*1.5);
incomeTax=0.08*gross_pay;
kwsp=0.10*gross_pay;
employee_union=10;
net_pay=gross_pay - (incomeTax + kwsp + employee_union);
}
else if ( hour>=51)
{
gross_pay=hour*(4.00*3.00);
incomeTax=0.08*gross_pay;
kwsp=0.10*gross_pay;
employee_union=10;
net_pay=gross_pay - (incomeTax + kwsp + employee_union);
}

cout<<"Gross Pay : RM "<<gross_pay<<endl;


cout<<"Net Pay : RM "<<net_pay;

getch( );

}
FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12
8

3 A student’s council at a particular university held a fund-raising campaign for MAKNA


(Cancer Association). A total of 10 students participate in this campaign.

You need to write a program that will input the student’s faculty and he/her contribution
amount to MAKNA. The program then will calculate the number of contributors by faculty,
the total amount contributed for each faculty and the average contribution for each faculty.

There are only three faculties involved which are : Computer, Business and Accounting.
Your program also needs to take care if the user enters a wrong faculty name.

The sample screen output as follows :-

Faculty Total Amount of contribution Number of contributions Average


Computer RMxxxxxx.xx xxx RMxxxxx.xx
Business RMxxxxxx.xx xxx RMxxxxx.xx
Accounting RMxxxxxx.xx xxx RMxxxxx.xx

ANSWER

# include <iostream.h>
# include <conio.h>
void main()
{
char name[10];
double amount;
int num,sum;
int count=1;
while (count<=10)
{

cout<<"student's faculty : ";


FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12
8

cin>>name;
if ( name == "computer")
{
cout<<"contribution amount to MAKNA : RM ";
cin>>amount;
}
else if ( name == "business")
{
cout<<"contribution amount to MAKNA : RM ";
cin>>amount;
}
else if ( name == "accounting")
{
cout<<"contribution amount to MAKNA : RM ";
cin>>amount;
}
sum+=num;
count++;
}

cout<<"Faculty\t\t Total amount of contribution\tNumber of contribution\tAverage";


cout<<"Computer\t\t RM RM";
cout<<"Business\t\t RM RM";
cout<<"Accounting\t RM RM";

getch ();

(sorry miss,I cant do it)

Vous aimerez peut-être aussi