Fundamentals of Computer Problem Solving: Assignment 3
Fundamentals of Computer Problem Solving: Assignment 3
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
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;
if ( char1 =='A')
{
cout<<"Subscription Year: ";
cin>>year;
total_fee=year*0;
cout<<"Years with the fee:RM "<<total_fee;
}
else if ( char1 =='B')
{
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.
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;
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);
}
getch( );
}
FUNDAMENTALS OF COMPUTER PROBLEM SOLVING CSC12
8
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.
ANSWER
# include <iostream.h>
# include <conio.h>
void main()
{
char name[10];
double amount;
int num,sum;
int count=1;
while (count<=10)
{
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++;
}
getch ();