Interest Calculation [munie,azam,haniff]

Go down

Interest Calculation [munie,azam,haniff]

Post  captain_LJ on Thu Dec 10, 2009 9:16 pm

using namespace std;

//base class..
class interest
              int x, y, z;
              interest(); //constructor..

              double rate, loan;
              int time, user;
              void nilai(double x, int y, double z); //declaration inline..
              virtual void message(void)
                      cout <<"\n      *******************************\n";
                      cout <<"      *  THE INTEREST CALCULATIONS  *\n";
                      cout <<"      *******************************\n\n";
                      cout <<"      SILA PILIH JENIS BAYARAN:\n";
                      cout <<"\n      1.Tahunan\n      2.Bulanan\n      3.Harian";
                      cout <<"\n\n      Masukkan no pilihan anda: ";
                      cin >>user;
                      cout <<"      ********************************";   

//implement interest constructor..
      x = y = z = 0;

//inline statements..
inline void interest::nilai(double x, int y, double z)
      loan = x;
      time = y;
      rate = z;

//derived class..
class calInterest:public interest
            double kira(int user)
                    if (user==1)
                    return (loan * rate * time)/100;
                    else if (user==2)
                    return (loan * rate * time /12)/100;
                    else if (user==3)
                    return (loan * rate * time /365)/100; 
            double kiraCom(int user)
                    return loan* pow(1 + rate/100,time);
            void tunjuklah()
                double x, z;
                cout <<"\n\n      Masukkan jumlah pinjaman:RM";
                cin >> x;
                cout << "\n      Kadar peratusan(%): ";
                cin >> z;
                cout << "\n      Tempoh bayaran: ";
                cin >> y;
                nilai(x, y, z);
                cout <<"\n      ********************************";
                cout <<"\n      Interest ialah RM "<<kira(user);
                cout <<"\n      ********************************";
                cout <<"\n      Compound ialah RM "<<kiraCom(user);
                cout <<"\n      ********************************\n\n";

int main()
    string d;
    string t = "tidak";
    //do statements..
          calInterest *tajuk; //declare pointed object
          tajuk=new calInterest; //create memory for class calInterest
          tajuk->message(); //object access to message()
          tajuk->tunjuklah(); //object access to display()
          delete tajuk; //delete memory created on tajuk
          cout <<"      Mau cuba lagi!!!!!.....\n";
          cout <<"      ****************************************************\n";
          cout <<"      Taip 'ya' untuk teruskan atau 'tidak' untuk berhenti: ";
          cin >> d;
          cout <<endl<<endl;
    //while statements..
    while (d!= t); //if true the program will be return..if not the program will close..
          cout <<"      Terima kasih kerana mencubanya!!....\n\n";
    return 0;

Number of posts : 5
Age : 27
Registration date : 2009-07-25

View user profile

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum