C++ console program help

IT_Kollek

Junior member
  • Mar 10, 2015
    82
    22
    8
    Ane bn me program eka karala diyankoo

    1) The program has to classes as class Loan and class Lease.
    • Class Loan has public function called FindInterest() which receives value of loan,period(in months)
    • and interest rate to find the interest of a loan.
    • class Lease has properties as lease value,lease period and lease rate.Class maintains function as SetLeaseData()
    • which set the values for lease value,lease period and lease rate.
    • Class Lease also use the function FindInterest() to find the interst amount of lease for all periods(in months).
    use main function to find;
    create an object for lease.
    use the object and call SetLeaseData() to set value for the lease and FindInterest() to find the interset of the lease

    Hint:
    Lease interest amount=lease value*interest rate * period;


    c++ valin bn one. me question ek avaradida mnda bn.matanm track vage me magula karaddi bn.
    ane bn help ekak diyankooo


    me mn karapu eka bn.mn meka kale turbo c vala :)


    Code:
    #include<iostream.h>
    #include<conio.h>
    class Loan{
    //int vloan,period,iRate,amt;
      public:
     virtual  void FindInterest(int a, int b, int c)=0;
        /* vloan=a;
         period=b;
         iRate =c;
         amt = vloan*period*iRate;
       }   */
    };
    
    class Lease:public Loan{
     int  lval,lperiod,IRate,amt ;
     public:
         void SetLeaseData(int a, int b, int c){
          lval=a;
          lperiod =b;
          IRate=c;
         }
         void FindInterest(){
    	amt=lval*IRate*lperiod;
    	cout<<amt;
         }
    };
    
    void main(){
    clrscr();
    Loan *l;
    Lease p;
    l=&p;
    
    l->SetLeaseData(20,5,6);
    l->SetLeaseData();
    getch();
    }
     
    Last edited:

    Amden

    Banned
    Sep 21, 2011
    339
    17
    0
    software එකක් හදන එකත් මාර ලේසි වැඩක් නේද බන්
    hahaha
    අන්ඩර දෙමල වාගේ නෙ බන් මේක
     

    IT_Kollek

    Junior member
  • Mar 10, 2015
    82
    22
    8
    thanx machoo
    software එකක් හදන එකත් මාර ලේසි වැඩක් නේද බන්
    hahaha
    අන්ඩර දෙමල වාගේ නෙ බන් මේක
    andara demala vage kivve bn mn liyala thiyena vidiye varaddakda??
    matanm hithenne prashne varadi vage bn :D
    e kiyala thiyena vidiyata thani object eken vade karanna ba bn.
    uda clz ekata data pass karanne nathuva vade venne na.mona magulakda mnda bn:angry::angry:
     

    sanzilla jackcat

    Well-known member
  • Oct 3, 2008
    6,744
    3,331
    113
    ෆ්ලුජා නගරය
    where you stuck ?

    One tip.
    When you set those values, you need to raise a flag that values have been set so when it calls to find the interest it would check whether you have set those values otherwise it will simply output a message saying "you need to set values before calculate the internet" , or simply throw an exception.

    Your virutal method FindInterest() in class Lease does not override the FindInterest() in Loan because it overload instead.

    Clear about what is overriding and overloading first.
     

    IT_Kollek

    Junior member
  • Mar 10, 2015
    82
    22
    8
    where you stuck ?

    One tip.
    When you set those values, you need to raise a flag that values have been set so when it calls to find the interest it would check whether you have set those values otherwise it will simply output a message saying "you need to set values before calculate the internet" , or simply throw an exception.

    Your virutal method FindInterest() in class Lease does not override the FindInterest() in Loan because it overload instead.

    Clear about what is overriding and overloading first.
    I think I have an idea about overriding n overloading. :D
    but the problem is if I create an object for class lease only,how to pass values to loan FindInterest()??
    question said about one object only Lease.

    please can u simply tell da answer?? :D
     

    IT_Kollek

    Junior member
  • Mar 10, 2015
    82
    22
    8
    c++ danne na kollo

    uba danna language ekakin karala diyanko bn dannavanam.awlk na language eka venas unata

    meke maha deyak na vage bn mata pena vidiyata
    aduma tharame inherit karannath one na vage bn.
    podi prashnayak.me mn karala thiyena eva karanna one na vage bn