Powered By Blogger

Saturday, March 26, 2011

Jawapan


SIFIR


#include <iostream.h>
main()
{
     cout<<"*****"<<endl;
     cout<<"SIFIR"<<endl;
     cout<<"*****"<<endl;
     int a,b;
     char o;
     a=1;
     while (a<=12)
     {
           cout<<"\n";
           for (b=1;b<=12;b++)
           {
               cout<<" "<<a*b;
               }
               a++;
               }
               cout<<"\n\nType EXIT to quit application"<<endl;
               cin>>o;
               return 0;
               }









MESIN TIN MINUMAN


#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;
}










2 comments:

  1. sorry miss..
    x perasaan x de gambar or nama..
    nie saya punya blog..
    Mohamad Saifol B. Johar

    ReplyDelete