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;

}

Sunday, February 27, 2011

Exercise Answer

Exercise 1

a) const double Pi=3.14;


b) double Parameter;


c)cout<<"input data";
cin>>data;


d) int num_compt;
cout<<"input number of computer";
cin>>num_compt;




Exercise 2

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


b) a = 5, b = 6 !((a < a ="="> 9))
!((5 < 5 ="="> 9))
!(1 && 0 0 )
!(00)
!(0)
1




Exercise 3

main()
{
float allowance=300.00;
float salary;
cout<<"Input Salary=";
cin>>salary;
Tsalary=salary+ Allowance;
cout>>"Salary is=" , salary;
}




Exercise 4

#include
main()
{
double day_salary;
int days=20;
double monthly_salary;


cout<<"enter day salary";
cin>>day_salary;
cout<<"enter days working";
cin>>days;

monthly_salary=Day_salary*days;
cout<<"Your monthly salary =", monthly_salary;
}




Exercise 5

Program that calculates the average of 5 numbers that can be input by user.

#include iostream.h
main()
{
int num1, num2, num3, num4, num5, average;
cout<<"enter number 1";
cin>>num1;
cout<<"enter number 2";
cin>>num2;
cout<<"enter number 3";
cin>>num3;
cout<<"enter number 4";
cin>>num4;
cout<<"enter number 5";
cin>>num5;

average=(num1+num2+num3+num4+num5)/5;
cout<<"average for five number is=" , average;


}






Exercise 6

Program that will calculate the area of rectangular, triangle and circle.

#include iostream.h
main()
{
double area_rect , area_triangle, area_circle, base , height, width, radius;
const double =3.14;
cout<<"Calculate area of rectangular.";
cout<<"Enter height=";
cin>>height;
cout<<"Enter width";
cin>>width;
area_rect=height * width;
cout<<"area of rectangular=", area_rect;


cout<<"Calculate area of triangle.";
cout<<"Enter base=";
cin>>base;
cout<<"Enter height";
cin>>height;
area_triangle= 1/2 * base * height ;
cout<<"area of triangle=", area_triangle;


cout<<"Calculate area of circle.";
cout<<"Enter radius=";
cin>>radius;
area_circle= 3.14;
cout<<"area of circle=", area_circle;


}

(Weekly Reflection 2)

*Msuk kls mcm biase dan sign attendance.
*Miss bg rehat stngh jam dan msuk smula kls pd pkul 10.
*Bljr chapter 2.
*Miss bg exercise 2 tntg coding (buat dlm kmpuln).
*Buat weely reflection by group.
*Balik.

Sunday, February 6, 2011

Example of Algorithm,Pseudocode, and Flowchart

Find the perimeter of a rectangle.The perimeter of the rectangle are given by the following formulas:



Perimeter=2*(length+width)



Algorithm:



1. Get the input variable length and width.

2. Calculate the perimeter by using the formula

perimeter=2*(length+width)

3. Display the perimeter.



Pseudocode:



START

Input length,width

Set the variable perimeter

perimeter=2*(length+width)

Print the perimeter

END





Flowchart:

FUNDAMENTAL OF PROGRAMMING (FOP)

Pd aq,sbjk FOP ssh & aq agk trkjt bile aq kne amek sbjek niwh.Tp dgn hti x rela,pkirn yg rnsing,jiwe yg kcau trpkse jgk r aq rgister sbjek FOP..huh!!! redha jelh aq...kah3..Tp aq akn bljr btol2 & aq akn fhmkn smua chpter yg ad dlm sbjek FOP niwh.Aq hrp,,Pn.Ayuni brsbr dlm mngajr aq..cz aq mmg ssh nk fhm bab2 programming & coding.Oklh,,Dlm sbjk FOP first2 skali,,aq bljr ape itu Algorithm,Pseudocode, & Flowchart.So,,ini yg dpt aq rungkaikn...

Algorithm:
Satu siri arahan yang ditulis menggunakan bahasa yang ditulis menggunakan bahasa yang boleh difahami untuk menyelesaikan masalah.

Pseudocode:
Langkah-langkah menyelesaian masalah yang ditulis menggunakan sebahagiannya bahasa pengaturcaraan tertentu dan sebahagiannya pula bahasa pertuturan biasa.

Flowchart:
Rajah-rajah yang menggunakan simbol-simbol grafik untuk menunjukkan proses atau langkah-langkah dalam penyelesaian masalah.


(Weekly Reflection 1)

*Kami dibahagikn kpd bbrpa kmpuln.

*Forum-Bincang pndpt masing2 tntg FOP.

*Weekly Reflection-Mnergkn ape yg aq bljr tntg FOP dlm masa 4 jam kls.

*Zip File diberi 5 mark (4 Assignment) dh x gne paper.

*Buat Blog (blogspot.com/wordpress.com)-10mark.

*Midterm-10 mark.

*Final-40 mark (15 mark br lulus).

*URL.

*Sesi perknln.

*Bljr Chpter 1:

-Algorithm

-Psedocode

-Flowchart

*Activity-Stiap kmpuln msti selesaikn krje yg miss bg & tulis jwpn di whiteboard.

INTRODUCTION OF FOP

Pd mulenya FOP just utk bdk course IT,tp thn niwh bdk E-BUSINESS kne amek plk sbjk niwh...em,,pning aq.X ke plik tetibe je bdk E-BUSINESS kne amek sbjk IT,,pork prnde jdnye... Tp ape bleh wt,,dh lcture ckp bdk E-BUSINESS wajib amek sbjk FOP niwh cz pnting bg bdk course E-BUSINESS sprti aq amek FOP ats sbb2 trtntu.Aq pown x twu ape sbb2 dye..haha~