Saturday, March 26, 2011

WEEKLY REFLECTION 5

1 March 2011, Tuesday 


We learn c + + as usual and we were given tasks to complete the following exercises in the Forum.

Answers will be sent and attach it in the Forum. Each group must make discussion of cooperation to complete their assignment before the end of class.

Finally, as usual for the [/list]Weekly Reflection for the week.


ASSIGNMENT 2 SIFIR


Saturday, March 19, 2011

WEEKLY REFLECTION 6

08 March 2011 
As'salamulaikum dan Salam Sejahtera...

- Macam biasa kami di beri masa rehat dari pukul 9.00 pagi hingga Pukul 10.00 Pagi

- Dari ahli kumpulan kami seorang tidak hadir iaitu Fatimah

- Miss telah memberi kami latihan yang Exercise Question Past Years, kemudian Miss memberi tempoh kepada kami untuk menyiapkan tugasan dari pukul 10.00 hingga 12.00 tengahari. Setelah tu, kami harus memberi jawapan di papan putih.Miss akan menyemak jawapan yang kami berikan..

- Setelah siap kesemua ye kami telah Miss telah memberikan kami tugasan iaitu Assignment yang kedua-2 iaitu Membuat Sifat menggunakan coding (looping)..

- Saya kurang cerdik  dalam tentang membuat coding walaupun saya ambik course IT...

- Antara contoh Contoh soalan seperti Loop. Terdapat 2 jenis Loop iaitu :-
  a) Do..While
  b) For 

- Antara Contoh coding ialah :-





EXERCISE IF...ELSE


EXERCISE 
CALCULATE :-


 Rectangular
      Triangle
      Circle
      Fahrenheit
      Calculus

Your selection :-
Your selection is _______________ and you are calculate ______________ .
The answer is _________________ .



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)
















EXERCISE (QUESTION PAST YEAR)


08 MARCH 2011

QUESTION 1
1.       Fill in the blank with appropriate data type for the following variables declaration syntax :-

a)      Numerik   (Integer)               Number 1=1
b)      Numerik   (Nombor Nyata) Number 3=3.0
c)       Bukan Numerik (Rentetan)Text 1=”1 have a car”
d)      Bukan Numerik (Aksara)      Huruf = “B”
e)      Bukan Numerik (Rentetan) AccountNo =”6666666443”

1.    2   You are be given PTPTN loan with the amount of RM 1600.00. Calculate the amount of after PTPTN discount based on the CGPA. You must us if…else statement :

CGPA
DISCOUNT

4.00


100%


3.99-3.00


80%


2.99-2.00

40%


0-1.99

0%


OUTPUT
Jumlah Pimjaman = RM 1600.00
CGPA yang Diperolehi = 3.00
Diskun = RM 12800.00
Jumlah pinjaman yang perlu dibayar selepas Diskun = RM 3200.00

Answer :-

#include <iostream.h>
main()
{
float cgpa, diskaun, jumlah_pinjaman, bayaran_pinjaman;
cout<<" Jumlah Pinjaman : ";
cin>>jumlah_pinjaman;
cout<<" CGPA yang diperoleh: ";
cin>>cgpa;

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

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

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

1.     3.  You are required to do a program that will execute the multiply or divide operation. The operating is based on the user’s. 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 darb 4 dan 8 ialah 32
Answer :

#include<iostream.h>
Main ()
{
    Int num1,num2,selction,total_multiy,total_divide ;

   Cout<<”Masukkan Nombor 1  =” ;
   Cin>>Nombor 1 ;

   Cout<<”Masukkan Nombor 2  =”  ;
   Cin>>Nombor 2 ;

    Cout<<”Masukkan Nombor Pilihan =”;
   Cin>>Pilihan ;

Switch(selection)
{
  Case 1 =(selection=1)
  Total_multiy =num1*num2 ;
  Cout<<”Hasil_Darab”<<Num1<<”dan”<<Num2<<”Total_Multiply<<endl ;

  Case 2 =(selection=2)
  Total_Divide=Num1/Num2 ;
  Cout<<”Hasil_Bahagi “<<Num1<<”dan”Num2<<”Total_Divide<<endl;

}
return 0
}


1.      4. Change the diagram expression to Arithmetic 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

    5.Solve the statement below to find in value. Show the working :-

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)


1.   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 “ ;


Answer :-

Output :
Cout<<Var1 bigger than Var 2 “ ;



b)    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;

}
        

Monday, February 28, 2011

PROGRAMMING EXERCISE SWITCH....CASE


#include<iostream.h>
main ()
{
     int selection,quantity;
     double price;

     cout<<"\n 1. Pen    =RM 0.50";
     cout<<"\n 2. Pensil =RM 0.30";
     cout<<"\n 3. Ruler  =RM 0.20";
     cout<<"\n 4. Erser  =RM 0.10"<<endl;

     cout<<"\n Enter your selection= ";
     cin>>selection;
     cout<<"\n Enter your quantity= ";
     cin>>quantity;

switch (selection)
{
     case 1:
price = quantity * 0.50;
cout<<"\n Price = RM "<<price<<endl;
cout<<"\n Your selection is Pen with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;
  
case 2:
price = quantity * 0.30;
cout<<"\n Price = RM "<<price<<endl;
cout<<"\n Your selection is Pensil with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;

     case 3:
price = quantity * 0.20;
cout<<"\n Price = RM  "<<price<<endl;
cout<<"\n Your selection is Ruler with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;
  
case 4:
price = quantity * 0.10;
cout<<"\n Price = RM  "<<price<<endl;
cout<<"\n Your selection is Erser with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;

default:
cout<<"\n Invalid selection"<<endl;
}

return 0;
}