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 ~

Weekly Reflection 2

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

- Buat blogspot & register forum.
- Menjawab latihan yg miss bagi dlm forum.
- Submit kerja rumah yg ada dlm forum.
- Miss ajar chapter 2.
- Contoh :

#include ---------->header
main()---------->body
{

return 0;
}

- Setiap kumpulan diberi soalan dan markah.
- Kami mendapat 3 markah sajew :'(
-

WE HAVE TO IMPROVE OURSELF (^_^)

~ Kelas Tamat ~

Sunday, February 27, 2011

Weekly Reflection 1

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

- Orientasi berkenalan sesame classmate (Malu²).
- Rehat 15 minit utk breakfast (Lapar²).
- Kami dibahagikan kpd beberapa kumpulan (Wakarima).
- FORUM : Bincang pendapat masing-masing (Ilham²).
- Weekly reflection menerangkan apa yg kita buat dlm masa 4 jam semasa di dlm kelas.
- Zip file diberi 5 markah(4 assignment)x gune paper.
- Buat blog samada blogspot.com/wordpress(10).
- Midterm 10 markah.
- Final 40 markah.
- URL , address : uttp://www.facebook.com
- Pengenalan subjek chapter 1.
- Kita belajar chapter 1 : algorithm , psedocode , flowchart .
- Algorithm : Ayatnye panjang (Bak kata Miss Ayuni) .
- Pseudo code : Bentuk pergerakkan program.
- Flowchart :
- Aktiviti : Setiap kumpulan musti selesai dan tulis di whiteboard , soalan yg miss bagi (Chaiyok!!).

- Kelas Tamat -

Friday, February 4, 2011

Pengenalan FOP

Hoyeh Hoyeyh.. bermulanya kelas FOP . ktokk ktokkk , aku mengetuk pintu . OMG !! Miss Ayuni da macok kelas.. aku lewat !!! fuh , nasib baik xde pape berlaku , hee . 1st time dalam kelas FOP , ada sesi perkenalan diri . malu woo . 2nd , kene buad group . haiyaa , dalam group aku , aku sorang laki , len sume pompuan . segan ouh.. nama group wakenabeb wakarima & diketuai oleh Anne . aku xtau pew maksud wakarima . dis is 1st time in my life I heard dat name (hanco english aku) HAHA .

lima minit kemudian , Miss bitau 6 benda wajib iaituu :
  1. forum
  2. weekly reflection (lepas tamat kelas)
  3. zip file (outcome 1 , 2 , 3 , 4)
  4. blog [blogspot.com , wordpress.com (10m)]
  5. midterm (10m)
  6. final (40m)
aiyoyoo , poning2 . tp xpew , semangatku xkan luntur begitu sajew , bak kata pepatah inggeris "life must be go on" , ngeh3 . aku dapat tau pasal search engine terhebat yg merangkumi sume search2 engine yg ada iaitu master search , heheh . lagi 1 pasal software yg aku akan guna utk wat FOP nanti turbo c++ , borland c++ , visual c++. aku x bape tau sgt pasal benda alah nie -.-"

after that , kitorang pon belajar laa bab 1 pasal algorithm , pseudocode & flow chart . aku penah belajar dulu masa subjek PPSC tp ingat2 lupe arh , hahaha ! yg aku tau algorithm ada nombor step by step . pseudocode pulak kene amek keyword drpd algorithm . flow chart ada kene hafal bentuk2 carta alir . pastu group kitorang (wakarima) kene wat pasal celcius convert to farenheit kat whiteboard .

lupe na bitau , FOP bermaksud Fundamentals of Programming . meow meoww , hehehe ~