Paano Makalkula ang Simple at Compound Interes

Paano Makalkula ang Simple at Compound Interes

Ang matematika ay isang mahalagang bahagi ng programa. Kung hindi mo malulutas ang mga simpleng problema sa lugar na ito, mas mahihirapan ka kaysa sa kailangang maging ganito.





Sa kasamaang palad, ang pag-aaral kung paano gawin ito ay hindi masyadong mahirap. Sa artikulong ito, matututunan mo kung paano makalkula ang simpleng interes at compound na interes gamit ang Python, C ++, at JavaScript.





kung paano kumuha ng isang screenshot nang walang print screen

Paano Mo Nakakalkula ang Simpleng Interes?

Ang simpleng interes ay isang pamamaraan upang makalkula ang dami ng interes na sisingilin sa isang prinsipyong halaga sa isang naibigay na rate at para sa isang naibigay na tagal ng panahon. Maaari mong kalkulahin ang simpleng interes sa pamamagitan ng paggamit ng sumusunod na pormula:





Simple Interest = (P x R x T)/100
Where,
P = Principle Amount
R = Rate
T = Time

Ang Pahayag ng Suliranin

Binigay ka halaga ng prinsipyo , rate ng interes , at oras . Kailangan mong kalkulahin at i-print ang simpleng interes para sa mga naibigay na halaga. Halimbawa : Hayaan ang prinsipyo = 1000, rate = 7, at timePeriod = 2. Simpleng Interes = (prinsipyo * rate * timePeriod) / 100 = (1000 * 7 * 2) / 100 = 140. Sa gayon, ang output ay 140.

Ang C ++ Program upang Makalkula ang Simpleng Pag-interes

Nasa ibaba ang programa ng C ++ upang makalkula ang simpleng interes:



// C++ program to calculate simple interest
// for given principle amount, time, and rate of interest.
#include
using namespace std;
// Function to calculate simple interest
float calculateSimpleInterest(float principle, float rate, float timePeriod)
{
return (principle * rate * timePeriod) / 100;
}

int main()
{
float principle1 = 1000;
float rate1 = 7;
float timePeriod1 = 2;
cout << 'Test case: 1' << endl;
cout << 'Principle amount: ' << principle1 << endl;
cout << 'Rate of interest: ' << rate1 << endl;
cout << 'Time period: ' << timePeriod1 << endl;
cout << 'Simple Interest: ' << calculateSimpleInterest(principle1, rate1, timePeriod1) << endl;
float principle2 = 5000;
float rate2 = 5;
float timePeriod2 = 1;
cout << 'Test case: 2' << endl;
cout << 'Principle amount: ' << principle2 << endl;
cout << 'Rate of interest: ' << rate2 << endl;
cout << 'Time period: ' << timePeriod2 << endl;
cout << 'Simple Interest: ' << calculateSimpleInterest(principle2, rate2, timePeriod2) << endl;
float principle3 = 5800;
float rate3 = 4;
float timePeriod3 = 6;
cout << 'Test case: 3' << endl;
cout << 'Principle amount: ' << principle3 << endl;
cout << 'Rate of interest: ' << rate3 << endl;
cout << 'Time period: ' << timePeriod3 << endl;
cout << 'Simple Interest: ' << calculateSimpleInterest(principle3, rate3, timePeriod3) << endl;
return 0;
}

Output:

Test case: 1
Principle amount: 1000
Rate of interest: 7
Time period: 2
Simple Interest: 140
Test case: 2
Principle amount: 5000
Rate of interest: 5
Time period: 1
Simple Interest: 250
Test case: 3
Principle amount: 5800
Rate of interest: 4
Time period: 6
Simple Interest: 1392

Kaugnay: Paano Makahanap ng Lahat ng Mga Kadahilanan ng isang Likas na Numero sa C ++, Python, at JavaScript





Ang Python Program upang Makalkula ang Simpleng Pag-interes

Nasa ibaba ang programa ng Python upang makalkula ang simpleng interes:

# Python program to calculate simple interest
# for given principle amount, time, and rate of interest.
# Function to calculate simple interest
def calculateSimpleInterest(principle, rate, timePeriod):
return (principle * rate * timePeriod) / 100

principle1 = 1000
rate1 = 7
timePeriod1 = 2
print('Test case: 1')
print('Principle amount:', principle1)
print('Rate of interest:', rate1)
print('Time period:', timePeriod1)
print('Simple Interest:', calculateSimpleInterest(principle1, rate1, timePeriod1))
principle2 = 5000
rate2 = 5
timePeriod2 = 1
print('Test case: 2')
print('Principle amount:', principle2)
print('Rate of interest:', rate2)
print('Time period:', timePeriod2)
print('Simple Interest:', calculateSimpleInterest(principle2, rate2, timePeriod2))
principle3 = 5800
rate3 = 4
timePeriod3 = 6
print('Test case: 3')
print('Principle amount:', principle3)
print('Rate of interest:', rate3)
print('Time period:', timePeriod3)
print('Simple Interest:', calculateSimpleInterest(principle3, rate3, timePeriod3))

Output:





Test case: 1
Principle amount: 1000
Rate of interest: 7
Time period: 2
Simple Interest: 140.0
Test case: 2
Principle amount: 5000
Rate of interest: 5
Time period: 1
Simple Interest: 250.0
Test case: 3
Principle amount: 5800
Rate of interest: 4
Time period: 6
Simple Interest: 1392.0

Kaugnay: Paano Kumpletuhin ang FizzBuzz Hamon sa Iba't ibang Mga Wika sa Programming

Ang Programang JavaScript upang Makalkula ang Simpleng Pag-interes

Nasa ibaba ang programa ng JavaScript upang makalkula ang simpleng interes:

// JavaScript program to calculate simple interest
// for given principle amount, time, and rate of interest.
// Function to calculate simple interest
function calculateSimpleInterest(principle, rate, timePeriod) {
return (principle * rate * timePeriod) / 100;
}
var principle1 = 1000;
var rate1 = 7;
var timePeriod1 = 2;
document.write('Test case: 1' + '
');
document.write('Principle amount: ' + principle1 + '
');
document.write('Rate of interest: ' + rate1 + '
');
document.write('Time period: ' + timePeriod1 + '
');
document.write('Simple Interest: ' + calculateSimpleInterest(principle1, rate1, timePeriod1) + '
');
var principle2 = 5000;
var rate2 = 5;
var timePeriod2 = 1;
document.write('Test case: 2' + '
');
document.write('Principle amount: ' + principle2 + '
');
document.write('Rate of interest: ' + rate2 + '
');
document.write('Time period: ' + timePeriod2 + '
');
document.write('Simple Interest: ' + calculateSimpleInterest(principle2, rate2, timePeriod2) + '
');
var principle3 = 5800;
var rate3 = 4;
var timePeriod3 = 6;
document.write('Test case: 3' + '
');
document.write('Principle amount: ' + principle3 + '
');
document.write('Rate of interest: ' + rate3 + '
');
document.write('Time period: ' + timePeriod3 + '
');
document.write('Simple Interest: ' + calculateSimpleInterest(principle3, rate3, timePeriod3) + '
');

Output:

Test case: 1
Principle amount: 1000
Rate of interest: 7
Time period: 2
Simple Interest: 140
Test case: 2
Principle amount: 5000
Rate of interest: 5
Time period: 1
Simple Interest: 250
Test case: 3
Principle amount: 5800
Rate of interest: 4
Time period: 6
Simple Interest: 1392

Paano Makalkula ang Compound Interes

Ang compound na interes ay ang pagdaragdag ng interes sa punong-guro na halaga. Sa madaling salita, interes ito sa interes. Maaari mong kalkulahin ang interes ng tambalan sa pamamagitan ng paggamit ng sumusunod na pormula:

Amount= P(1 + R/100)T
Compound Interest = Amount – P
Where,
P = Principle Amount
R = Rate
T = Time

Ang Pahayag ng Suliranin

Binigay ka halaga ng prinsipyo , rate ng interes , at oras . Kailangan mong kalkulahin at i-print ang compound na interes para sa mga ibinigay na halaga. Halimbawa : Hayaan ang prinsipyo = 1000, rate = 7, at orasPeriod = 2. Halaga = P (1 + R / 100) T = 1144.9 Compound Interes = Halaga - Halaga ng Prinsipyo = 1144.9 - 1000 = 144.9 Kaya, ang output ay 144.9.

Ang C ++ Program upang Kalkulahin ang Compound Interes

Nasa ibaba ang programa ng C ++ upang makalkula ang interes ng tambalan:

// C++ program to calculate compound interest
// for given principle amount, time, and rate of interest.
#include
using namespace std;
// Function to calculate compound interest
float calculateCompoundInterest(float principle, float rate, float timePeriod)
{
double amount = principle * (pow((1 + rate / 100), timePeriod));
return amount - principle;
}
int main()
{
float principle1 = 1000;
float rate1 = 7;
float timePeriod1 = 2;
cout << 'Test case: 1' << endl;
cout << 'Principle amount: ' << principle1 << endl;
cout << 'Rate of interest: ' << rate1 << endl;
cout << 'Time period: ' << timePeriod1 << endl;
cout << 'Compound Interest: ' << calculateCompoundInterest(principle1, rate1, timePeriod1) << endl;
float principle2 = 5000;
float rate2 = 5;
float timePeriod2 = 1;
cout << 'Test case: 2' << endl;
cout << 'Principle amount: ' << principle2 << endl;
cout << 'Rate of interest: ' << rate2 << endl;
cout << 'Time period: ' << timePeriod2 << endl;
cout << 'Compound Interest: ' << calculateCompoundInterest(principle2, rate2, timePeriod2) << endl;
float principle3 = 5800;
float rate3 = 4;
float timePeriod3 = 6;
cout << 'Test case: 3' << endl;
cout << 'Principle amount: ' << principle3 << endl;
cout << 'Rate of interest: ' << rate3 << endl;
cout << 'Time period: ' << timePeriod3 << endl;
cout << 'Compound Interest: ' << calculateCompoundInterest(principle3, rate3, timePeriod3) << endl;
return 0;
}

Output:

Test case: 1
Principle amount: 1000
Rate of interest: 7
Time period: 2
Compound Interest: 144.9
Test case: 2
Principle amount: 5000
Rate of interest: 5
Time period: 1
Compound Interest: 250
Test case: 3
Principle amount: 5800
Rate of interest: 4
Time period: 6
Compound Interest: 1538.85

Kaugnay: Paano Baligtarin ang isang Array sa C ++, Python, at JavaScript

kung paano mabawi ang mga tinanggal na mensahe sa facebook

Ang Python Program upang Makalkula ang Compound Interes

Nasa ibaba ang programa ng Python upang makalkula ang interes ng tambalan:

# Python program to calculate compound interest
# for given principle amount, time, and rate of interest.
# Function to calculate compound interest
def calculateCompoundInterest(principle, rate, timePeriod):
amount = principle * (pow((1 + rate / 100), timePeriod))
return amount - principle
principle1 = 1000
rate1 = 7
timePeriod1 = 2
print('Test case: 1')
print('Principle amount:', principle1)
print('Rate of interest:', rate1)
print('Time period:', timePeriod1)
print('Compound Interest:', calculateCompoundInterest(principle1, rate1, timePeriod1))
principle2 = 5000
rate2 = 5
timePeriod2 = 1
print('Test case: 2')
print('Principle amount:', principle2)
print('Rate of interest:', rate2)
print('Time period:', timePeriod2)
print('Compound Interest:', calculateCompoundInterest(principle2, rate2, timePeriod2))
principle3 = 5800
rate3 = 4
timePeriod3 = 6
print('Test case: 3')
print('Principle amount:', principle3)
print('Rate of interest:', rate3)
print('Time period:', timePeriod3)
print('Compound Interest:', calculateCompoundInterest(principle3, rate3, timePeriod3))

Output:

Test case: 1
Principle amount: 1000
Rate of interest: 7
Time period: 2
Compound Interest: 144.9000000000001
Test case: 2
Principle amount: 5000
Rate of interest: 5
Time period: 1
Compound Interest: 250.0
Test case: 3
Principle amount: 5800
Rate of interest: 4
Time period: 6
Compound Interest: 1538.8503072768026

Kaugnay: Paano Mahahanap ang Kabuuan ng Lahat ng Mga Sangkap sa isang Array

Ang Program sa JavaScript upang Kalkulahin ang Compound Interes

Nasa ibaba ang programa ng JavaScript upang makalkula ang interes ng tambalan:

// JavaScript program to calculate compound interest
// for given principle amount, time, and rate of interest.

// Function to calculate compound interest
function calculateCompoundInterest(principle, rate, timePeriod) {
var amount = principle * (Math.pow((1 + rate / 100), timePeriod));
return amount - principle;
}
var principle1 = 1000;
var rate1 = 7;
var timePeriod1 = 2;
document.write('Test case: 1' + '
');
document.write('Principle amount: ' + principle1 + '
');
document.write('Rate of interest: ' + rate1 + '
');
document.write('Time period: ' + timePeriod1 + '
');
document.write('Compound Interest: ' + calculateCompoundInterest(principle1, rate1, timePeriod1) + '
');
var principle2 = 5000;
var rate2 = 5;
var timePeriod2 = 1;
document.write('Test case: 2' + '
');
document.write('Principle amount: ' + principle2 + '
');
document.write('Rate of interest: ' + rate2 + '
');
document.write('Time period: ' + timePeriod2 + '
');
document.write('Compound Interest: ' + calculateCompoundInterest(principle2, rate2, timePeriod2) + '
');
var principle3 = 5800;
var rate3 = 4;
var timePeriod3 = 6;
document.write('Test case: 3' + '
');
document.write('Principle amount: ' + principle3 + '
');
document.write('Rate of interest: ' + rate3 + '
');
document.write('Time period: ' + timePeriod3 + '
');
document.write('Compound Interest: ' + calculateCompoundInterest(principle3, rate3, timePeriod3) + '
');

Output:

Test case: 1
Principle amount: 1000
Rate of interest: 7
Time period: 2
Compound Interest: 144.9000000000001
Test case: 2
Principle amount: 5000
Rate of interest: 5
Time period: 1
Compound Interest: 250
Test case: 3
Principle amount: 5800
Rate of interest: 4
Time period: 6
Compound Interest: 1538.8503072768008

Alamin ang Code nang Libre: Magsimula Sa Simple at Compound Interes

Ngayong mga araw na ito, ang epekto ng pag-coding ay lumalaki nang exponentially. At alinsunod dito, ang pangangailangan para sa mga may kasanayan sa mga coder ay tumataas din exponentially. Mayroong isang maling kuru-kuro sa mga tao na matututunan nilang mag-code lamang pagkatapos magbayad ng isang mataas na bayarin. Ngunit hindi iyon totoo. Maaari mong malaman ang ganap na mag-code nang libre mula sa mga platform tulad ng freeCodeCamp, Khan Academy, YouTube, at iba pa. Kaya, kahit na wala kang malaking badyet, hindi mo kailangang mag-alala tungkol sa pagkawala.

Magbahagi Magbahagi Mag-tweet Email Ang 7 Pinakamahusay na Paraan upang Alamin Kung Paano Mag-code nang Libre

Hindi ka maaaring malaman na mag-code nang libre. Maliban kung bibigyan mo ang mga nasubukan at nasubok na mapagkukunang ito, syempre.

Basahin Susunod
Mga Kaugnay na Paksa
  • Programming
  • Sawa
  • JavaScript
  • Mga Tutorial sa Coding
Tungkol sa May-akda Yuvraj Chandra(60 Mga Artikulo Na-publish)

Si Yuvraj ay isang undergraduate na mag-aaral sa Computer Science sa University of Delhi, India. Masigasig siya sa Full Stack Web Development. Kapag hindi siya nagsusulat, sinisiyasat niya ang lalim ng iba't ibang mga teknolohiya.

Higit pa Mula kay Yuvraj Chandra

Mag-subscribe sa aming newsletter

Sumali sa aming newsletter para sa mga tip sa tech, pagsusuri, libreng ebook, at eksklusibong deal!

Mag-click dito upang mag-subscribe