Jumaat, 11 Mac 2011

FOP Weekly Reflection 6

Class start kol 10 dgn exercise minggu lepas miss nk tgk. jawapan yg betul akan ditulis didepan. selepas soalan 1 dan 2 siap dipaparkan semua students menyalin bagi yg salah. lepas itu miss ajar Loop. dan ade memberi contoh Loop


selepas miss mengajar loop miss memberi latihan individu kerana miss ingin semua students mahir dalam fop. exercise yg diberi adalah.
1. fill in the blank with the appropriate data types for the following variable declaration syntax
a. _________ number 1=1
b. _________ number 3=30
c. _________ text 1=" i have a car"
d. _________ huruf = "b"
e. _________ account no = "6666666443"

2. you are given PTPTN loan with the amount of rm16000. calculate the amount that you should pay other PTPTN discount based on the CGPA. you must use if...else statement
Output
Jumlah pinjaman = rm16.000
CGPA yg diperoleh = 3.00
Diskaun = rm 12.800

#include <iostrean.h>
main()
{
      //declare variable
      float (cgpa,discount,jumlah_pinjaman,bayaran_pinjaman;
      cout<<"jumlah pinjaman=";
      cin>>jumlah_pinjaman;
      cout<<"cgpa yg diperolehi=";
      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 yg perlu dibayar selepas="<<bayaran_pinjaman<<endl;


3. you are required to do program that will execute the multiply or divided operation is based on the user's choice. you must use switch.....case statement
Output:

#include <iostream.h>
main()
{
      //Declare variable
      int num1,num2,selection,total_multiply,total_divided;
    
      cout<<"masukkan nombor 1=";
      cin>>num1;
      cout<<"masukkan nombor kedua=";
      cin>>num2;
      cout<<"masukkan pilihan anda=";
      cin>>selection;
      switch(selection)
{
case 1:(selection=1)
     total_multiply = num1*num2;
     cout<<hasil darab"<<num1<<"dan<<num2<<"ialah"<<total_multiply endl;
     break
case 2:(selection=2)
     total_divide = num1/num2;
     cout<<hasil_bahagi"<<num1<<"dan<<num2<<"ialah"<<total_divide endl:
     break
}
return 0;
}



4.change the algebra expression to anthmetic expression

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

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"; 
b) int n = 20; n/= 5;

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


8. write of program that needs 4 prices using while loop and calculates the sum of the thing a program must use function while for calculate the average of the price.
#include <iostream.h> 
main() 
int k; 
float P,total,average; 
K=1 
while(k<=4) 
{
cout<<"Enter price"<<K<<"=j;
cin>>P;
ktt; total=total+P; 
}
average=total/4;
cout<<"your total is"<<total<<"and average is" average;
return0; 
}




FOP Weekly Reflection 5

Mcm biasa class start kol 10. Masuk Class miss Bagi Exercise iaitu:
Soalan 1

MESIN TIN MINUMAN (SWITCH...CASE)
*****************
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)


Soalan 2
CALCULATE (IF...ELSE)
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS

Your Selection:

Your Selection is _________ and you are calculate _________. The answer is _____________
setiap group kena buat 2 soalan yg diberi oleh miss. miss beri bagi masa smpi ko 12 lebih bagi menyiapkan soalan diatas. bagi group nas faris sedaya-upaya menyiapkan 2 soalan yg diberikn oleh miss. selepas siap dan di check oleh miss ade beberapa kesalahan yg dilakukan oleh group nas. tapi miss tidak memberi jawapan bagi soalan 1 dan 2. Sbb miss nk suwh students buat dulu baru miss bagi jawapan yg betul. sebeleum mengakhiri class miss ingat melihat jawapan soalan 1 dan 2 di minggu depan.

Jawapan Soalan 1

#include <iostream.h>
main()
{
      //declare
      int selection;
      float money,balance,price,addm,add;
      //out
      cout<<"******************"<<endl;
      cout<<"Mesin Tin Minuman"<<endl;
      cout<<"------------------"<<endl;
      cout<<"1.PEPSI";
      cout<<"\n2.COCA COLA";
      cout<<"\n3.F&N MIRINDA";
      cout<<"\n4.F&N ORANGE";
      cout<<"\n5.100 PLUS"<<endl;
      cout<<"******************"<<endl;
      //input
      cout<<"\nPlease Choose Your Drink"<<endl;
      cin>>selection;
    
      cout<<"\nPlease Enter MONEY: ";
      cin>>money;
    
      switch (selection)
      {
             case 1: cout<<" Your drink is Pepsi";
                     price = 2.00;
                     break;
             case 2: cout<<" Your drink is Coca Cola";
                     price = 2.00;
                     break;
             case 3: cout<<" Your drink is F&N Mirinda";
                     price = 1.80;
                     break;
             case 4: cout<<" Your drink is F&N Orange";
                     price = 1.80;
                     break;
             case 5: cout<<" Your drink is 100 Plus";
                     price = 2.50;
                     break;
             default: cout<<"invalid selection";
             }
    
      if (money>price)
      {
                      balance = money - price;
      }else if (money<price){
                            add = price - money;
                            cout<<"Please add (RM" <<add<< ")= ";
                            cin>>addm;
                            balance = money + addm;
                            }
                            cout<<"Your balance is "<<balance;
                            return 0;
}