0% found this document useful (0 votes)
17 views1 page

Untitled Document 6

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Untitled Document 6

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

NAME: Shankar Srangire

BRANCH:CO3K
Practical:8
#include <iostream>
using namespace std;
class SimpleInterest {
private:
float principal;
float duration;
static float rate_of_interest;
public:
void readData() {
cout << "Enter Principal amount: ";
cin >> principal;
cout << "Enter Duration (in years): ";
cin >> duration;
}
static void setRateOfInterest(float rate) {
rate_of_interest = rate;
}
// Function to calculate simple interest
float calculateInterest() {
return (principal * duration * rate_of_interest) / 100;
}
void display() {
cout << "Principal: " << principal << endl;
cout << "Duration: " << duration << " years" << endl;
cout << "Rate of Interest: " << rate_of_interest << "%" << endl;
cout << "Simple Interest: " << calculateInterest() << endl;
}
};
float SimpleInterest::rate_of_interest = 0;
int main() {
SimpleInterest si;
si.readData();
SimpleInterest::setRateOfInterest(5.5); // Set the rate of interest
si.display();return 0;

You might also like