Tuesday, 5 April 2011
WEEKLY REFLECTION 8
-Seperti biase,kami diberi rehat selama 1 jam.
-PN. AYUNI,memberi kami paper MIDTERM.
-Kami diberi tempoh sehingga pukul 12.00 tengahari untuk membuat
correction MIDTERM dan perlu menghantarnya.
-Selepas itu,PN. AYUNI memberitahu bahawa FOP akan ade PROJECT.
-Kami berbincang didalam kumpulan,untuk membuat project FOP.
Monday, 28 March 2011
CONTOH MID TERM EXAMINATION
EXERCISE
1. Fill in the blank with the appropriate data types for the following variable declaration syntax
a .integer number 1=1
b. float number 3=30
c. string text 1=" i have a car"
d. string huruf = "b"
e. string account no = "6666666443"
2. You are given PTPTN loan with the amount of rm16000. calculate the amount that you should pay other PTPTN discount based on the CGPA. you must use if...else statement
Output
Jumlah pinjaman = rm16.000
CGPA yg diperoleh = 3.00
Diskaun = rm 12.800
Jumlah pinjaman yang perlu dibayar selepas diskaun = RM3200
3. You are required to do program that will execute the multiply or divided operation is based on the user's choice. you must use switch.....case statement
Output:
answer :
4.Change the algebra expression to anthmetic expression
1. Fill in the blank with the appropriate data types for the following variable declaration syntax
a .integer number 1=1
b. float number 3=30
c. string text 1=" i have a car"
d. string huruf = "b"
e. string account no = "6666666443"
2. You are given PTPTN loan with the amount of rm16000. calculate the amount that you should pay other PTPTN discount based on the CGPA. you must use if...else statement
Output
Jumlah pinjaman = rm16.000
CGPA yg diperoleh = 3.00
Diskaun = rm 12.800
Jumlah pinjaman yang perlu dibayar selepas diskaun = RM3200
3. You are required to do program that will execute the multiply or divided operation is based on the user's choice. you must use switch.....case statement
Output:
answer :
4.Change the algebra expression to anthmetic expression
a) Y = m – 4ax
7a
Answer : Y = (m - 4 ax) / 7a
b) Y = 6ab___
4sd – 2xy
Answer : Y = 6 bc / (4 sd – 2xy)
c) Y = 2 + (AB + ( ) + 5 xyz
3d
Answer : Y = (( 2 + AB + c ) / 3d ) + 5 xyz
d) Y = 2kb = 3jb
2k1
Answer : Y = (2kb / 2 ki ) – 3 jb
e) Y = xy + x2 – 2ab
Answer : Y= xy + x * x – 2 ab
Solve the statement below to find in value. Show the working :-
6. Find the output for the following segment:-
a) float var 1 = 25.12, var 2 = 15.0;
if (var 1<= var 2) cout<<"var 1 less or same as var 2"; else cout<<"var 1 bigger than var 2";
b) int n = 20; n/= 5;
7. Convert the while statement below for for statement :-
{
a) M=5
M * = (3 + 4) * 2
Answer :-
M = 5 * ( 3 + 4 ) * 2
M = (5 * 7 )* 2
M = 35 * 2
M = 70
1 (TRUE)
b) M=2
M * = ((3 *4 ) / 2 ) = 9
Answer :-
M = 2 * (12/ 2 ) =9
M = ( 2* 6 ) = 9
M = 12 = 9
0 (FALSE)
6. Find the output for the following segment:-
a) float var 1 = 25.12, var 2 = 15.0;
if (var 1<= var 2) cout<<"var 1 less or same as var 2"; else cout<<"var 1 bigger than var 2";
b) int n = 20; n/= 5;
Answer :-
Output :
Cout<<Var1 bigger than Var 2 “ ;
<!--[if !supportLists]-->b) <!--[endif]-->In n = 20 ;
n/ = 5 ;
Answer :-
Output :
Cout<<20 / 5 = 4 “ ;
7. Convert the while statement below for for statement :-
Int j = 10 ;
While ( j > 10)
{
Cout << “ “ << j ;
J______ ;
}
Answer :-
#incude<iostream.h>
Main ()
{
//declare variable
Int x ;
X = 1 ;
While (x < = 10 )
{
Cout<<”number “<<x*1 ;
X ++ ;
}
return 0;
}
Output :
Number 1 --------- 1
2 --------- 2
3 --------- 3
4 --------- 4
5 --------- 5
6 --------- 6
7 --------- 7
8 --------- 8
9 --------- 9
10 --------- 10
8.Write a program the reads 4 prices using while loop and calculate the sum of things. A program must use function while for calculate the average of the prices.
#include<iostream.h>
main ()
{
int k;
float p,total,averge;
k=1;
while (k<=4)
{
cout<<"Enter price "<<k<<"= ;
cin>>p;
k++;
total=total+p;
}
Average=total/4;
cout<<"Your total is "<<total<<"and average is "average;
return 0;
}
WEEKLY REFLECTION 7
-seperti biase,kami diberi rehat selama 1 jam.
-PN.AYUNI mengarahkan student FOP,supaya menyiapkan segala tugasan yang telah diberikan selama ini ke dalam blog.
-kami diberi mase sehingga pukul 1.oo petang.
-PN.AYUNI mengarahkan student FOP,supaya menyiapkan segala tugasan yang telah diberikan selama ini ke dalam blog.
-kami diberi mase sehingga pukul 1.oo petang.
EXERCISE
Exercise
1. Write correct C++ syntax & for each statement below:
a) Initializing variable Pi with the value 3.14 (constant)
answer :
float pi =3.142;
b) Declare a variable named Perimeter with double data type (declare variable)
answer :
double perimeter
c) Give instruction that allowed user to input data (input)
answer :
int data;
//input
cout<<"enter your data";
cin>>data;
d) Input number of computer using variable (input assign to variable value)
answer :
int number;
cin>>number;
2. Solve the question below. Show the working.
a) 5 * 2 % 3 + 25 / 5
answer :
= [10%3]+25/5
= 1+[25/5]
= 1+5
= 6
b) a = 5, b = 6
!((a < 3) && (a == 3) || (b > 9))
answer :
= !((5<3)&&(5 == 3) || (6>9))
= !((0) &&(0) || (0)
= !((0) (0)
= !(0)
= 1
3. Identify syntax errors in the following program. (5errors)
include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Salary is= "<< salary;
}
answer :#include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Total Salary is= "<< Tsalary;
return 0;}
4. Write a program that will calculate the monthly salary for an employee that where Saturday and Sunday are considered as non-working days.
answer :
5. Write a program that calculates the average of 5 numbers that can be input by user.
answer :
6. Write a program that will calculate the area of rectangular, triangle and circle.
answer :
a) Initializing variable Pi with the value 3.14 (constant)
answer :
float pi =3.142;
b) Declare a variable named Perimeter with double data type (declare variable)
answer :
double perimeter
c) Give instruction that allowed user to input data (input)
answer :
int data;
//input
cout<<"enter your data";
cin>>data;
d) Input number of computer using variable (input assign to variable value)
answer :
int number;
cin>>number;
2. Solve the question below. Show the working.
a) 5 * 2 % 3 + 25 / 5
answer :
= [10%3]+25/5
= 1+[25/5]
= 1+5
= 6
b) a = 5, b = 6
!((a < 3) && (a == 3) || (b > 9))
answer :
= !((5<3)&&(5 == 3) || (6>9))
= !((0) &&(0) || (0)
= !((0) (0)
= !(0)
= 1
3. Identify syntax errors in the following program. (5errors)
include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Salary is= "<< salary;
}
answer :#include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Total Salary is= "<< Tsalary;
return 0;}
4. Write a program that will calculate the monthly salary for an employee that where Saturday and Sunday are considered as non-working days.
answer :
5. Write a program that calculates the average of 5 numbers that can be input by user.
answer :
6. Write a program that will calculate the area of rectangular, triangle and circle.
answer :
ASSIGNMENT 1 MESIN TIN MINUMAN (SWITCH...CASE)
1. MESIN TIN MINUMAN (SWITCH...CASE & IF...ELSE)
*************************
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)
*************************
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)
Subscribe to:
Posts (Atom)