1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
class KRA; //declaring a class
void receive_stamp_duty (); //function prototype whose definition is below
int main ()
{
receive_stamp_duty ();
return 0;
}
class KRA
{
private:
int stamp_duty_received, Land_value,stamp_duty_amount, balance;
string Surname, OtherNames, LandNum, KraPin, OwnerIdCard;
public:
KRA (){} //default constructor
KRA (string a, string b, string c,string d,string e) //overloaded constructor
{
a = Surname;
b=OtherNames;
c= LandNum;
d=KraPin;
e=OwnerIdCard;
}
void setLandvalue (int value) //setter function
{
Land_value =value;
}
void setReceivedMoney (int received ) //setter function
{
stamp_duty_received = received;
}
int calc_stamp_duty_amount (int &Land_value); //function defined out of class as below
int calc_balance (int&, int&); //function defined out of class as below
void receive_stamp_duty ();
static const string transact; //a default string-no longer in use
};
//const string KRA:: transactionState ="cleared";
//calc balance, stamp_duty_amount (a 15% of Land value)
int KRA:: calc_stamp_duty_amount (int &Land_value)
{
stamp_duty_amount = 15% Land_value;
return stamp_duty_amount ;
}
int KRA::calc_balance (int &stamp_duty_received, int &stamp_duty_amount)
{
balance= stamp_duty_amount - stamp_duty_received;
return balance;
}
void KRA :: receive_stamp_duty ()
{
std::cout <<"Enter the value of Land on Sale\n";
cin>>Land_value;
cin.clear ();
std::cout<<"You should pay stamp duty amount :\n"<<calc_stamp_duty_amount (Land_value)<<endl;
std::cout<<"Enter the amount received in respect of land transaction stamp duty:\n";
std::cin>>stamp_duty_received;
setReceivedMoney(stamp_duty_received);
if (stamp_duty_received ==stamp_duty_amount)
{
std::cout<<"Transaction stamp duty has been paid in full\n"<<endl;
ofstream enter ("Transactions.txt", ios::app);
/*
executes some more code here
*/
enter.close();
}
if (stamp_duty_received < stamp_duty_amount)
{
std::cout<<"Stamp duty fee should be: \n"<<stamp_duty_amount<<" .Please pay ksh.\n" <<calc_balance (stamp_duty_received, stamp_duty_amount)<<"more !"<<endl;
ofstream enter ("Transactions.txt", ios::app);
/*
executes some more code here
*/
enter.close();
}
}
|