Monday, March 28, 2011

Answer For Exercise 8/3/2011:

EXERCISE NO 1

a) int Number 1=1
b) float Number 3=3.0
c) string Text 1=”1 have a car”
d) char Huruf = “B”
e) int AccountNo =”6666666443”

EXERCISE NO 2

#include
main ()
{
float cgpa,diskaun,jumlah_pinjaman,bayaran_pinjaman;
cout<<"Jumlah pinjaman";
cin>>jumlah_pinjaman;
cout<<"CGPA yang diperolah:";
cin>>cgpa;


if ((cgpa>=3.99)&&(cgpa<=3.00));
diskaun=jumlah_pinjaman*80/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<cout<<"Jumlah pinjaman yang perlu dibayar
selepas diskaun="<

if ((cgpa>2.99)&&(cgpa<=2.00));
diskaun=jumlah_pinjaman*40/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<cout<<"Jumlah pinjaman yang perlu dibayar
selepas diskaun="<

if (cgpa=4.00);
diskaun=jumlah_pinjaman*100/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<cout<<"Jumlah pinjaman yang perlu dibayar
selepas diskaun="<

}
return 0;
}

EXERCISE NO 3

#include
main ()
{
//Declare variable
int num1,num2,selection,total_multiply,total_divided;

cout<<"masukkan nombor satu";
cin>>num1;
cout<<"masukkan nombor dua";
cin>>num 2;
cout<<"masukkan pilihan anda";
cin>>selection;
Switch(selection)
{
case 1:(selection=1)
total_multiply=num1*num2;
cout< ialah"< break;
case 2:(selection=2)
total_divided=num1/num2;
cout< ialah"< break;
}
return 0;
}


EXERCISE NO 4

i) y=(m-4ax)/79
ii) y=6bc/(45s-2xy)
iii) y=((2+AB+C)/3d)+5xyz
iv) y=(2kb/2ki)-3jb
v) y=xy+x*x-2ab


EXERCISE NO 5

a) m=5
m*=m(3+4)*2
m=5*5(7)*2
m=25*14
m=350


b) m=2
m*=((3*4)1/2)-9
m=2*(12*1/2)-9
m=2*6-9
m=12-9
m=3

EXERCISE NO 6

a) float var 1=25.12, var 2=15.0;
if (var 1<=2)
cout<<"var1 less or same as var2";
else
cout<<"var1 bigger than var2";

output:
if(25.12<=2)
var 1 bigger than var 2


b) int n=20;
n/=5;

output:
n=n/5
n=20/5
n=4

EXERCISE NO 7

int j;
for(j=10;j>0;j--)
{
cout<<" "<}

EXERCISE NO 8

#include
main()
{

int k;
float P,average;
float total;
k=1 ;
while (k<=4)
{
cout<<"Enter price";
cin>>P;
k++;
}

total=P+P+P+P;
cout<<"\nyour total is"<average=total/4;
cout<<"\nyour average is"<return 0;
}

---------------------------------------------------------------------------------------

Exercise 8/3/2011:

QUESTION NO 1

Fill in the blank with appropriate data type for the
following variables declaration syntax :

a) __________Number 1=1
b) __________Number 3=3.0
c) __________Text 1=”1 have a car”
d) __________Huruf = “B”
e) __________AccountNo =”6666666443”

QUESTION NO 2

You are given PTPTN loan with the amount of RM1600.Calculate the amount that you should pay after PTPTN discount based on CGPA.You must use IF…ELSE Statement:

CGPA Diskaun
4.00 100%
3.99 – 3.00 80%
2.99 – 2.00 40%
0 – 1.99 0%




Contoh output:
Jumlah pinjaman: RM16000.00
CGPA yang diperolehi:3.00
Diskaun:RM 12800
Jumlah oinjaman yang perlu dibayar selepas diskaun: RM3200

QUESTION NO 3

You are required to do a program that will execute the multiply or divide operation.The operation is based on the user’s choice.You must use SWITCH-CASE STATEMENT:
Output:
____________________________________________
MENU PILIHAN
____________________________________________
1.Pendaraban
2.Pembahagian
__________________________________________
Masukkan nombor pertama:4
Masukkan nombor kedua:8
Masukkan pilihan anda:1
Hasil darab 4 8 ialah 32

QUESTION NO 4

Change the algebra expression to anathematic expression:

QUESTION NO 5

Solve the statement below to find m value show the working:
a) m=5
m*=m(3+4)*2
b) m=2
m*=((3*4)1/2)-9

QUESTION NO 6

Find the output for the following segment:-
a) float var 1=25.12, var 2=15.0;
if (var 1<=2)cout<<"var1 less or same as var2";
else cout<<"var1 bigger than var2";

b) in n=20; n/=5;

QUESTION NO 7

Convert the while statement below for statement
int j=10; while (j>0)
{
cout<<" "<J--J
}

QUESTION NO 8

Write of program that needs 4 prices using while loop
and calculate the sum of the thing a program must
use function while for calculate the average of the
prices.


#include
main ()
{
int k;
float P,total,average;
K=1
while (k<=4)
{
cout<<"Enter price"<cin>>P;
k++; total=total+P;
}
average=total/4;
cout<<"your total is"<return 0;
}

Saturday, March 26, 2011

WEEKLY REFLECTION:

(Weekly Reflection 5)

*Aku msuk kls ,then ad 7 org je kt dlm kls...cz yg laen lom dtg lg....
*Miss msuk kls..dan miss sruh kteorg rht dlu.then pkul 10 msuk smula dlm kls.
*Hbis time rehat,trus miss bg ltihn.
*Miss sruh siapkn latiahn yg miss bg (buat dlm kmpulan).
*Rmi yg x dpt slesaikn ltihn yg miss bg..then, miss inform next week miss bg jwpn untk ltihn uw..
*Last skali miss bg blek...hehe~

(Weekly Reflection 4)

*Aku dtg kls pd pkul 9.45 pg.
*Miss bg rehat smpi pkul 10.
*Msuk smula kls dan miss sruh kteorg download nota 1 smpi 6 dlm forum.
*Miss ajr chapter 4 tntg:
-Arithmetic Operators
-Relational Operators
-Logical Operators
*Miss bg ltihan (buat dlm group).
*Miss bg kteorg homework dan msti hntr before next week dan buat dlm blog.
*Pulang ke rumah msing2....

(Weekly Reflection 3)

Aku x dtg time niwh...so,aq copy paste dr forum group aq (WAKARIMA).
*Mula je kls, miss sruh ulg kaji chapter 1 dan 2.
*Buat exercise dlm kls chapter 1 dan 2 tntg Flowchart dan Coding (Programming c++).Miss Ayuni sruh buat dlm kls then attach kt forum then reply pd miss.
*Buat homework 1 dan 2 (homework ni pown kne attach kt forum).
*Lps siap smua kje,,kteorg di bnrkn pulg..^__^

ASSIGNMENT 2 (OUTPUT SIFIR LOOP)


ASSIGNMENT 2 (SIFIR LOOP)

#include
int main ( )
{
cout << " \t\t\t SIFIR " ,<< endl << " " << endl;
for (int c=1; c<13; c++)
for (int i=1; i<13; i++)
{
cout ,<< i * c << '\t';
}
cout << endl;
return O;
}

Monday, March 7, 2011

FOP Answer Exercise no. 1 & 2 (1/3/2011)

Answer Exercise 2

Include

main ()

{

float rectangular, circle, triangle, fahrenheit, celcius, radius,f,c;

float width,height,base;

char selection;

cout<<"calculate:";

cout<<"\n\n a-rectangular";

cout<<" \nb-triangle";

cout<<"\nc-circle";

cout<<"\nd-fahrenheit";

cout<<"\ne-celcius";

cout<<"\n\nenter selection";

cin>>selection;

if (selection=='a')

{

cout<<"\nYour Selection is a and you are calculate rectangular.";

cout<<"\nenter width";

cin>>width;

cout<<"\nenter height";

cin>>height;

rectangular=width*height;

cout<<"\nthe answer is"<

}

else if (selection=='b')

{

cout<<"\nYour Selection is b and you are calculate triangle.";

cout<<"\nenter base";

cin>>base;

cout<<"\nenter height";

cin>>height;

cout<<"\nthe answer is"<

triangle=(1/2*base*height);

}

else if (selection=='c')

{

circle=3.142 * radius * radius;

cout<<"\nYour Selection is c and you are calculate circle.";

cout<<"\n enter radius";

cin>>radius;

cout<<"\nthe answer is"<

}

else if (selection=='d')

{

;

cout<<"\nYour Selection is d and you are calculate fahrenheit.";

fahrenheit=(celcius*1/8)+32;

cout<<"\nenter celcius";

cin>>c;

cout<<"\nthe answer is"<

}

else

{

cout<<"\nYour Selection is e and you are calculate celcius.";

cout<<"\nenter fahrenheit";

cin>>f;

cout<<"\nthe answer is"<

celcius=(f-32)*(5/9);

}

return 0;

}

Answer Exercise 1

#include

main()

{

int drink;

double price;

double money;

double balance;

cout<<"**********";

cout<<"\n Mesin tin minuman";

cout<<"\n ------------------";

cout<<"\n 1 - pepsi\t\t 2.00\n 2 - coca cola\t\t2.00\n 3 - F&N MIRINDA \t1.80\n 4 - F&N ORANGE\t\t1.80\n 5 - 100 plus\t\t2.50";

cout<<"\n *********";

cout<<"\n\n enter your drink";

cin>>drink;

cout<<"\n enter your money";

cin>>money;

if (drink==1)

{

balance=money-2.00;

cout<<"\n your drink is pepsi";

cout<<"\n Balance is"<

}

else

if(drink==2)

{

balance=money-2.00;

cout<<"\n your drink is coca cola";

cout<<"\n Balance is"<

}

else

if(drink==3)

{balance= money-1.80;

cout<<"\n your drink is F$N MIRINDA";

cout<<"\n Balance is"<

else

if(drink==4)

{

balance = money-1.80;

cout<<"\n your drink is f&n orange";

cout<<"\n Balance is"<

}

else

if(drink==5)

{

balance=money-2.50;

cout<<"\n your drink is 100 plus";

cout<<"\n Balance is"<

}

else

{

cout<<" \n Invalid selection. Try again";

}

return 0;

}