Sunday, 27 February 2011

EXERCISE FOP IN BLOG

EXERCISE  IN BLOG.


QUESTION.


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 are 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. a) Initializing variable Pi with the value 3.14 (constant).


   //declare
   float Pi=3.14


   b)Declare a variable named Parameter with double data type (declare variable)


   //declare Parameter
   double Parameter=5.776198


    c)Give instruction that allowed user to input data (input)


    //input
     cout<<"Enter data=" ;
     cin>>data;


   d)Input number of computer using variable (input assign to variable value)


      //declare nc=number of computer
      int nc;

    //Input
    cout<<”Enter number of computer=” ;
    cin>>nc;


2. a) 5 * 2 % 3 + 25 / 5

    = [10%3]+25/5
    = 1+5
    = 6

   b)  a = 5, b = 6
       ! ((a < 3) && (a == 3) || (b > 9))

    = ! [(0) && (0) || (0)]
    =1


3Identify syntax errors in the following program.








4. Write a program that will calculate the monthly salary for an employee that where                              Saturday and Sunday are 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.


  
#include <iostream.h>
main()
{
      //declare
      float b,h,r,w,area,;
      float pi=3.14;
      int selection;
      //out
      cout<<"Please 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"<<endl;
                     cin>>h;
                     cout<<"Please input the width"<<endl;
                     cin>>w;
                     //process
                     area = w*h;
                     cout<<"The area is:"<<area;
                     break;
             case 2: cout<<"Please input the height"<<endl;
                     cin>>h;
                     cout<<"Please input the base"<<endl;
                     cin>>b;
                     //process
                     area = 0.5*b*h;
                     cout<<"The area is:"<<area;
                     break;
             case 3: cout<<"Please input the radius"<<endl;
                     cin>>r;
                     //process
                     area = pi*r*r;
                     cout<<"The area is:"<<area;
                     break;
             default :cout<<"Invalid Selection";
             return 0;
             }
}

Tuesday, 22 February 2011

WEEKLY REFLACTION 4

  • Class pada hari ini agak mencabar bagi I tapi I suka pada cabaran ini.
  • Dalam kelas hari ini miss sporting bagi brekfearst dulu and kelas star pukul 10 a.m.
  • miss arahkan all sudn downlod note chapter1,2,3,4,6 in forum.
  • Bermula la pegenalan subjek 4 :OPERATORS AND EXPRESSION.
  • Bab ini mengenai, ARTIHMETIC OPERATORS,RELATIONAL,LOGICAL.
  • Ini asas sahaja... :)
  • Kemudian mengenai  INCIMENT yang terbahagi kepada 2 iaitu: PRE-INCIMENT & POST-INCIMENT.
  • Later,DECREMENT terbahagi kepada dua: PRE-DECREMENT & POST-DECREMENT.
  • And baut exercise bab 4 yg miss bagi di dalam kelas by group.
  • Selepas habis bab4,terus kepada bab6 yang mencabar bagi aku..hehehe :)
  • Bab ini baru sampai mengenai IF...ELSE & SWITCH....CASE
  • Enjoy betul dalam kelas ini cz 4hour..hehehe :)
  • Group partner yang tidak hadir pada hari ini adalah. Nurfadatul Akmar.
  • Last,buat weekly reflection 4 by Group in forum..
  • EXERCISE YANG LAST WEEK GROUP I  dapat FULL MARK..:):):):)
  • HAPPY SANGAT,, :) 
EXERCISE1  (GROUP ECHELON TECH.)




#include<iostream.h>
main()
{
//variable
float as1,as2,as3,as4,as5,mid,final,total;
//input1
cout<<"assignment 1:";
cin>>as1;
//input2
cout<<"assignment 2:";
cin>>as2;
//input3
cout<<"assignment 3:";
cin>>as3;
//input4
cout<<"assignment 4:";
cin>>as4;
//input5
cout<<"assignment 5:";
cin>>as5;
//input6
cout<<"midterm:";
cin>>mid;
//input7
cout<<"final:";
cin>>final;
//formula
total = as1+as2+as3+as4+as5+mid+final;
//output
cout<<"assignment 1 is:"<<as1<<endl;
cout<<"assignment 2 is:"<<as2<<endl; 
cout<<"assignment 3 is:"<<as3<<endl;
cout<<"assignment 4 is:"<<as4<<endl;
cout<<"assignment 5 is:"<<as5<<endl;
cout<<"mid score is:"<<mid<<endl;
cout<<"final score is:"<<final<<endl;
cout<<"total is:"<<total;
return 0;
}

EXERSISE 2



#include <iostream.h>
main ()
{
//variable
float sub1,sub2,sub3,sub4,sub5,cpa;
//input1
cout<<"insert subject1:";
cin>>sub1;
//input2
cout<<"insert subject2:";
cin>>sub2;
//input3
cout<<"insert subject3:";
cin>>sub3;
//input4
cout<<"insert subject4:";
cin>>sub4;
//input5
cout<<"insert subject5:";
cin>>sub5;
//process
cpa=((sub1*3)+(sub2*3)+(sub3*2)+(sub4*2)+(sub5*4))/5;
//output
cout<<"subject 1:"<<sub1<<endl;
cout<<"subject 2:"<<sub2<<endl;
cout<<"subject 3:"<<sub3<<endl;
cout<<"subject 4:"<<sub4<<endl;
cout<<"subject 5:"<<sub5<<endl;
cout<<"CPA is:"<<cpa<<endl;
return 0;
}









NOTE CHAPTER4.
OPERATORS AND EXPRESSION.


1. OPERATORS IN C++ PROGRAMMING LANGUAGE.


a)ARITHMETIC OPERATORS.
+-->addition.
_ --> subtraction.
* -->multiplication.
/ -->devision.
% -->modulus.


2.RELATIONAL OPERATORS.
> : greater than.
< : less than.
>= :greater than and equal.
=< :less than and equal.
== :equal.


3.LOGICAL OPERATOR.
&& :and.
! :not.
|| :or.


4.INCIMENT AND DECREAMENT.


INCEMENT=A)Pre-inciment(++n)
                      B)Post-incimeny(n++)


DECREMENT=A)Pre-decrement(--n)
                        B)Post-decrement(n--)


5.CONTOH SOALAN.


a)int n;
    n=5;


   cout<<n;5
   cout<<++n;1+5
   cout<<n;6


b)int m;
   m=10;
   cout<<m;10
   cout<<m--;10
   cout m;9










    Thursday, 17 February 2011

    WEEKLY REFLACTION3 MAI

    • breakfast 9 to 10am :). 
    • class download C++ 32bit in forum(turbo).
    • study blog-spot in class :) :) best..
    • first step.. :)
    • register G.Mail.
    • create your blog.
    • name your blog.
    • start blogging.
    • dashboard & create blog.
    • design nice go to( btemplates.com/tag/education.xml)
    • INTRODUCTION CHAPTER 3.
    • DATA TYPE & VARIABLE.
    • The C++ character set.
    • keyword
    • BASIC DATA TYPE.
    1. integer data type.
    2. floating point data.
    3. character data type.
    4. size of operator.
    5. identifier.
    6. variable.
    7. dector variable.
    8. initializing variable.
    9. constants.
    10. othr data type.
    • FINISH,& do weekly reflection 3 in forum FOP by group.
    • smua ahli hadir.
    • next week 15/2/2011 no class cz maulidir rasul :)
    • homework di by group & send in forum FOP.
    • today class only 4 hour...best  :):):)

       EXERCISE WEEK3 by group in class FOP.

      • calculate 3 number with using the formula below:
      • calculate = (num1*num2)-num3+(num2/num1)


      #include<iostream.h>
      main()
      {
      //declare variable
      float num1,num2,num3,calculate;
      //input1
      cout<<"Enter Num1";
      cin>>num1;
      //input2
      cout<<"Enter Num2";
      cin>>num2;
      //input3
      cout<<"Enter Num3";
      cin>>num3;
      //formula
      calculate=(num1*num2)-num3+(num2/num1);
      //output
      cout<<"Answer is="<<calculate;
      return 0;
      }

      Tuesday, 1 February 2011

      WEEKLY REFLACTION 2 MAI.

       -First,regisrer forum in web http://lect-ayuni.forumms.net
      -Miss bg ms 45 minit utk msukkan ttg pergezaan antra
      Procudural Programming,Structure Programming n Object Orientend Programming ke dlm forum di web http://lect-ayuni.forumms.net  n do by group.
      -Bg emel blog n forum pd miss.
      -Pengenalan bab2 ttg C++ Programming Language.
      -Miss bg kerja by group tuk wt Programming n miss bg mark.






      -Then,masukkn weekly reflecttion 1 ke dalam forum.
      -Then,msukkn ttg Multiply Two Integers by group ni ke dlm forum.
      -Tugasan takhir bt weekly reflection 2 by group in class n list in forum.
      -faris n izwan tidak hadir pd hr ini..
      :):):)see u..



      C++ PROGRAM
      (perkara wajib dalam c++)


      #INCLUDE<iostream.h>-------->HEADER
      ---------------------------------------------------------
      main()---->BODY
      {//open curly bracket ---->START
      }//close curly bracket---->END


      __________________________________________________________________________________



      • IN BODY (dalam body)

      1.variable:to declare variable
      2.variable_name;  --->SEMIKOLEM



      • INPUT
      cout<<"ENTER your radius=";
      cin>>radius;



      • OUTPUT
      COUT<"area='<<area'
      __________________________________________________________________________________


      (rangka buat)






      #include<iostream.h>
      main()
      {
      //declare variable
      float pi,radius;
      //input radius
      cout<<"Enter radius=";
      cin>>radius;
      //formula
      pi=3.145*r*r;
      //output
      cout<<"area="<<pi;
      return o;
      }








      DATA TYPE.


      INTEGER int =no 0-9
      FLOAT=decimal
      DOUBLE=decimal
      CONSTANT const=formula akan jadi statik dan kekal
      CHARACTER char=1 perkataan
      STRING=perkataan panjang.





      EXERCISER BY GROUP IN CHAPTER2.

       PROGRAMING EXERCISE 1 FOP.

      Multiply Two Integers




      #include<iostream.h>
      main()
      {

      //Declare variable
      int multiply,num1,num2;

      //Input num1
      cout<<"Enter num1 =";
      cin>>num1;

      //Input num2
      cout<<"Enter Num 2 =";
      cin>>num2;

      //Formula
      multiply=num1*num2;

      //Output
      cout<<"mutiply= "<<mutiply;
      return 0;
      }


      CONTOH LATIHAN DALAM KELAS

      1) Sum and Minus Two Integers


      #include<iostream.h>
      main( )
      {
      //declare variable
      float sum,minus,num1,num2;
      //input1
      cout<<''num1='';
      cin>>num1;
      //input2
      cout<<''num2='';
      cin>>num2;
      //formula
      sum=num1+num2;
      minus=num2-num1;
      //output
      cout<<''sum=''<<sum;
      cout<<''minus=''<<minus;
      return 0;
      }

      2)Divide and Modulus Two Integers


      #include<iostream.h>
      main( )
      {
      //declare variable
      float divide, modulus, Num1, Num2;
      //Input 1 
      cout<<"Num1= ";
      cin>>Num1;
      //Input 2
      cout<<"Num2= ";
      cin>>Num2 ;
      //formula
      Divide=Num2/Num1;
      Modulus=Num1%Num2;
      //Output
      cout<<"divide="<<divide;
      cout<<"modulus="<<modulus;
      return 0;
      }


      3)Fahrenheit Convert to Celcius


      #include<iostream.h>
      main( )
      {

      float celcius;
      float farenheit;

      cout<<"Enter farenheit=";
      cin>>farenheit;

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

      cout<<"farenheit= "<<farenheit;
      cout<<"celcius= "<<celcius;

      return 0;
      }

      4)Celcius Convert to Fahrenheit


      #include<iostream.h>
      main()
      {
      float celcius,farenheit;
      cout<< "Enter celcius=";
      cin>>celcius;
      farenheit=9/5*(celcius+32);
      cout<<"Celcius="<<celcius;
      cout<<"Farenheit="<<farenheit;
      return 0;
      }