Monday, March 28, 2011

Homework 2

Subject 1 (0.00) :
Subject 2 (0.00) :
Subject 3 (0.00) :
Subject 4 (0.00) :
Subject 5 (0.00) :

CPA:

FORMULA:
CPA = ((Subject1*3) + (Subject2*3) + (Subject3*2) + (Subject4*2) + (Subject5*4)) / 5



Answer :


#include < iostream.h >
main()
{

//declair variable
float s1, s2, s3, s4, s5, cpa;

cout<<"Muhammad FIrdaus Bin Hasmi" << endl;
cout<<"05-201006-00003" << endl;

//input1
cout<<"\nSubject 1 = ";
cin>>s1;

//input2
cout<<"Subject 2 = ";
cin>>s2;

//input3
cout<<"Subject 3 = ";
cin>>s3;

//input4
cout<<"Subject 4 = ";
cin>>s4;

//input5
cout<<"Subject 5 = ";
cin>>s5;

//process
cpa=(((s1*3)+(s2*3)+(s3*2)+(s4*2)+(s5*4))/5);

//output
cout<<"\nSubject 1 : " << s1;
cout<<"\nSubject 2 : " << s2;
cout<<"\nSubject 3 : " << s3;
cout<<"\nSubject 4 : " << s4;
cout<<"\nSubject 5 : " << s5 << endl;
cout<<"\nCPA is : " << cpa << endl << endl;

return 0;
}


Questions :

Homework 1

Questions :

Assignment 1 (10%):
Assignment 2 (10%):
Assignment 3 (10%):
Assignment 4 (10%):
Assignment 5 (10%):
MidTerm (10%):
Final (40%):

TOTAL (100%):

FORMULA:
TOTAL = Assignment1+Assignment2+Assignment3+Assignment4+Assignment5+MidTerm+Final



Answer :



#include < iostream.h >
main()
{

//declair variable
float ass1, ass2, ass3, ass4, ass5, mid, final, total;

cout<<"Muhammad FIrdaus Bin Hasmi" << endl;
cout<<"05-201006-00003" << endl;

//input1
cout<<"\nassignment 1 = ";
cin>>ass1;

//input2
cout<<"assignment 2 = ";
cin>>ass2;

//input3
cout<<"assignment 3 = ";
cin>>ass3;

//input4
cout<<"assignment 4 = ";
cin>>ass4;

//input5
cout<<"assignment 5 = ";
cin>>ass5;

//input6
cout<<"midterm = ";
cin>>mid;

//input7
cout<<"final = ";
cin>>final;

//formula
total=ass1+ass2+ass3+ass4+ass5+mid+final;

//output
cout<<"\nOutput :- " << endl;
cout<<"assignment 1 = " << ass1 << endl;
cout<<"assignment 2 = " << ass2 << endl;
cout<<"assignment 3 = " << ass3 << endl;
cout<<"assignment 4 = " << ass4 << endl;
cout<<"assignment 5 = " << ass5 << endl;
cout<<"midterm = " << mid << endl;
cout<<"final = " << final << endl;
cout<<"\ntotal = " << total << endl << endl;

return 0;
}

Sunday, March 27, 2011

Buat Sifir



#include < iostream.h >
main()
{

//declair variable
int i, j;
char exit;

cout<<"Muhammad FIrdaus Bin Hasmi" << endl;
cout<<"05-201006-00003" << endl;

cout<<"\n*****";
cout<<"\nSIFIR";
cout<<"\n*****" << endl;

i=1;
while (i<=12)
{
cout<<"\n";
for (j=1; j<=12; j++)
{
cout<<" "<< i*j;
}
i++;
}
cout<<"\n\nType EXIT to close=";
cin>>exit;

return 0;
}

Mesin Minuman Tin (SWITCH...CASE)



*****************
MESIN TIN MINUMAN
-----------------
1- PEPSI
2- COCA COLA
3- F&N MIRINDA
4- F&N ORANGE
5- 100 PLUS
*****************

Enter your drink:
Enter your money (RM):

Your drink is __________ and your balance are __________

*If the customer does not enter enough money, asked the customer to insert the money. (if...else)



Answer :

#include < iostream.h >
#include < string.h >
#include < conio.h >
#include < stdio.h >

int main()
{

//declare variable
int selection;
float price, money;
char drink[50];

cout<<"\n**********";
cout<<"\nMESIN TIN MINUMAN";
cout<<"\n__________";
cout<<"\n1.PEPSI";
cout<<"\n2.COCA COLA";
cout<<"\n3.F&N MIRINDA";
cout<<"\n4.F&N ORANGE";
cout<<"\n5.100 PLUS";
cout<<"\n**********\n";

cout<<"Enter your drink=";
cin>>selection;
cout<<"Enter you money=";
cin>>money;

//switch...case
switch (selection)
{

case 1: strcpy(drink,"PEPSI");
price=1.70;
break;

case 2: strcpy(drink,"COCA COLA");
price=1.80;
break;

case 3: //drink[50]="F&N MIRINDA";
price=1.50;
break;

case 4: //drink="F&N ORANGE";
price=1.30;
break;

case 5: //drink="100 PLUS";
price=1.60;
break;

default: cout<<"invalid selection";

}

if(money>price)
{
float balance=money-price;
cout<<"your drink is " << drink;
cout<<" and your balance are" << balance;


}
else
{


/*add=price-money;
please add (RM << add << )=
cin>>add_money;
balance=money+add_money;
cout<<"your drink is" << drink << and your balance
are << balance;
*/
}


getch();

return 0;
}



Questions :

Monday, February 28, 2011

Exercises (23/02/2011)

1. Write correct C++ syntax & for each statement below:
a) Initializing variable Pi with the value 3.14 (constant)
b) Declare a variable named Parameter with double data type (declare variable)
c) Give instruction that allowed user to input data (input)
d) Input number of computer using variable (input assign to variable value)

2. Solve the question below. Show the working.
a) 5 * 2 % 3 + 25 / 5
b) a = 5, b = 6
!((a < 3) && (a == 3) || (b > 9))

3. Identify syntax errors in the following program.

include < iostream.h >
main()
{
float allowance = 300.00, salary;

cout<<"Input Salary = ";
cin>>salary;

TSalary = salary + Allowance;

cout<<"Salary is= "<< salary;
}

4. Write a program that will calculate the monthly salary for an employee that where Saturday and Sunday considered as non-working days.

5. Write a program that calculates the average of 5 numbers that can be input by user.

6. Write a program that will calculate the area of rectangular, triangle and circle.


Answer :

1. Write correct C++ syntax & for each statement below :

a) const pi = 3.14

b) double parameter;

c) cout>>"Enter your data: ";
cin<< data;

d) int num;
num = 3;
cout>>"Number= "<< num;


2. Solve the question below. Show the working.

a) 5 * 2 % 3 + 25 / 5
10 % 3 + 25 / 5
1 + 25 / 5
1 + 5
= 6

b) a=5 , b=6
!((a<3) && (a==3) || (b>a))
!((5<3) && (5==3) || (6>5))
!((0) && (0) || (0))
!(0) || (0)
!(0)
= 1 or T (True)


3. Identify syntax errors in the following program.

i) #include < iostream.h >

ii) float TSalary;

iii) cout<<"input_salary=";

iv) return 0;

v) }


4.Write a program that will calculate the monthly salary for an employee that where Saturday and Sunday considered as non-working days


#include < iostream.h >
main()
{

//declare
float allowance=500.00, salary=40, tsalary, day;

cout<<"Muhammad FIrdaus Bin Hasmi" << endl;
cout<<"05-201006-00003" << endl;

//input
cout<<"\nease input total days work = ";
cin>>day;

//process
tsalary = (salary*day)+allowance;

//output
cout<<"The total salary for this month is = RM " << tsalary << endl << endl;

return 0;
}





5. Write a program that calculates the average of 5 numbers that can be input by user.


#include < iostream.h >
main()
{

//declaire variable
float num1, num2, num3, num4, num5, average;

cout<<"Muhammad Firdaus Bin Hasmi";
cout<<"05-201006-00003";

//input 1
cout<<"Enter Number 1 = ";
cin>>num1;

//input 2
cout<<"Enter Number 2 = ";
cin>>num2;

//input 3
cout<<"Enter number 3 = ";
cin>>num3;

//input 4
cout<<"Enter Number 4 = ";
cin>>num4;

//input 5
cout<<"Enter number 5 = ";
cin>>num5;

//formula
average=(num1+num2+num3+num4+num5);

//output
cout<<"The answer is = " << average <
return 0;
}




6. Write a program that will calculate the area of rectangular, triangle and circle.


#include < iostream.h >
main()
{
//declaire
float b, h, r, w, area;
float pi=3.14;
int selection;

//out
cout<<"Muhammad FIrdaus Bin Hasmi" << endl;
cout<<"05-201006-00003" << endl;

cout<<"\nPlease choose you choice" << endl;
cout<<"1.Rectangular";
cout<<"\n2.Triangle";
cout<<"\n3.Circle" << endl;
cin>>selection;
switch (selection)
{
case 1: cout<<"Please input the height = ";
cin>>h;
cout<<"Please input the width = ";
cin>>w;
//process
area = w*h;
cout<<"The area is = " << area << endl < break;

case 2: cout<<"Please input the height = ";
cin>>h;
cout<<"Please input the base = ";
cin>>b;
//process
area = 0.5*b*h;
cout<<"The area is:" << area << endl << endl;
break;

case 3: cout<<"Please input the radius = " << endl;
cin>>r;
//process
area = pi*r*r;
cout<<"The area is:" << area << endl << endl;
break;

default :cout<<"Invalid Selection";
}


return 0;
}

Weekly Reflection 4

Selama 4 jam berada di kelas FOP (^_^)

Chapter 4 :

- Buat arithematic operators.
- Relational operators.
- Logical operators.
- Increment & decrement.
- Try doing the maths.
- Kami belajar bagaimana na guna if...else & switch...case statement...
- Miss bagi kitorang exercise 2 buat dlm kelas & homework exercises...upload kat blog (individual).

Time ni aku x hadir sbb bgn lewat.. Maaf ye miss.. hehe :P

~ Kelas Tamat ~

Weekly Reflection 3

Selama 4 jam berada di kelas FOP (^_^)

8/2/2011
Starting blajar ulangkaji chapter 1& 2.
Buat exercise dlm class chapter 1& 2 tentang Flowchart dan coding (Programming C++)
Buat dalam class then attach pd FORUM then reply pada Miss Ayuni.
After that doing the homework 1& 2 and attach pada Forum too.
After all finished,we can go back now!!



Yg hadir:Daus,Anne & Eka

*yg tak datang: wany,thana & nozy.*

schazy

Posts: 9
Join date: 31/01/2011

~ Kelas Tamat ~