Πώς να υπολογίσετε το απλό και το σύνθετο ενδιαφέρον

Πώς να υπολογίσετε το απλό και το σύνθετο ενδιαφέρον

Τα μαθηματικά είναι αναπόσπαστο μέρος του προγραμματισμού. Εάν δεν μπορείτε να λύσετε απλά προβλήματα σε αυτόν τον τομέα, θα αγωνιστείτε πολύ περισσότερο από ό, τι πρέπει να συμβεί.





Ευτυχώς, το να μάθεις πώς να το κάνεις δεν είναι πολύ δύσκολο. Σε αυτό το άρθρο, θα μάθετε πώς να υπολογίζετε το απλό ενδιαφέρον και το σύνθετο ενδιαφέρον χρησιμοποιώντας Python, C ++ και JavaScript.





πώς να επιστρέψετε στο κλασικό gmail

Πώς υπολογίζετε το απλό επιτόκιο;

Ο απλός τόκος είναι μια μέθοδος για τον υπολογισμό του ποσού των τόκων που χρεώνονται σε ένα βασικό ποσό σε ένα δεδομένο επιτόκιο και για μια δεδομένη χρονική περίοδο. Μπορείτε να υπολογίσετε το απλό επιτόκιο χρησιμοποιώντας τον ακόλουθο τύπο:





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

Η Δήλωση Προβλήματος

Είσαι δεδομένος αρχικό ποσό , βαθμός ενδιαφέροντος , και χρόνος Το Πρέπει να υπολογίσετε και να εκτυπώσετε το απλό ενδιαφέρον για τις δεδομένες τιμές. Παράδειγμα : Αφήστε την αρχή = 1000, ποσοστό = 7, και timePeriod = 2. Απλό ενδιαφέρον = (αρχή * ποσοστό * timePeriod) / 100 = (1000 * 7 * 2) / 100 = 140. Έτσι, η έξοδος είναι 140.

Το πρόγραμμα C ++ για τον υπολογισμό του απλού ενδιαφέροντος

Παρακάτω είναι το πρόγραμμα C ++ για τον υπολογισμό του απλού επιτοκίου:



// 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;
}

Παραγωγή:

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

Σχετικά: Πώς να βρείτε όλους τους συντελεστές ενός φυσικού αριθμού σε C ++, Python και JavaScript





Το πρόγραμμα Python για τον υπολογισμό του απλού ενδιαφέροντος

Παρακάτω είναι το πρόγραμμα Python για τον υπολογισμό του απλού επιτοκίου:

# 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))

Παραγωγή:





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

Σχετίζεται με: Πώς να ολοκληρώσετε την πρόκληση FizzBuzz σε διαφορετικές γλώσσες προγραμματισμού

Το πρόγραμμα JavaScript για τον υπολογισμό του απλού ενδιαφέροντος

Παρακάτω είναι το πρόγραμμα JavaScript για τον υπολογισμό του απλού ενδιαφέροντος:

// 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) + '
');

Παραγωγή:

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

Τρόπος υπολογισμού σύνθετων τόκων

Σύνθετοι τόκοι είναι η προσθήκη τόκων στο κύριο ποσό. Με άλλα λόγια, είναι συμφέρον επί τόκου. Μπορείτε να υπολογίσετε το σύνθετο ενδιαφέρον χρησιμοποιώντας τον ακόλουθο τύπο:

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

Η Δήλωση Προβλήματος

Είσαι δεδομένος αρχικό ποσό , βαθμός ενδιαφέροντος , και χρόνος Το Πρέπει να υπολογίσετε και να εκτυπώσετε το σύνθετο ενδιαφέρον για τις δεδομένες τιμές. Παράδειγμα : Έστω αρχή = 1000, ποσοστό = 7, και χρόνος Περίοδος = 2. Ποσό = Ρ (1 + Ρ/100) Τ = 1144,9 Σύνθετος τόκος = Ποσό - Ποσό αρχής = 1144,9 - 1000 = 144,9 Έτσι, η έξοδος είναι 144,9.

Το πρόγραμμα C ++ για τον υπολογισμό σύνθετων τόκων

Παρακάτω είναι το πρόγραμμα C ++ για τον υπολογισμό των σύνθετων τόκων:

// 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;
}

Παραγωγή:

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

Σχετίζεται με: Πώς να αντιστρέψετε έναν πίνακα σε C ++, Python και JavaScript

τα παράθυρα δεν μπόρεσαν να εντοπίσουν τις ρυθμίσεις διακομιστή μεσολάβησης αυτού του δικτύου

Το πρόγραμμα Python για τον υπολογισμό σύνθετων τόκων

Παρακάτω είναι το πρόγραμμα Python για τον υπολογισμό των σύνθετων τόκων:

# 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))

Παραγωγή:

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

Σχετίζεται με: Πώς να βρείτε το άθροισμα όλων των στοιχείων σε έναν πίνακα

Το πρόγραμμα JavaScript για τον υπολογισμό σύνθετων τόκων

Παρακάτω είναι το πρόγραμμα JavaScript για τον υπολογισμό του σύνθετου ενδιαφέροντος:

// 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) + '
');

Παραγωγή:

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

Μάθετε να κωδικοποιείτε δωρεάν: Ξεκινήστε με απλό και σύνθετο ενδιαφέρον

Σήμερα, ο αντίκτυπος της κωδικοποίησης αυξάνεται εκθετικά. Και σύμφωνα με αυτό, η ζήτηση για ικανούς κωδικοποιητές αυξάνεται επίσης εκθετικά. Υπάρχει μια εσφαλμένη αντίληψη μεταξύ των ανθρώπων ότι μπορούν να μάθουν να κωδικοποιούν μόνο αφού πληρώσουν υψηλό τέλος. Αλλά αυτό δεν είναι αλήθεια. Μπορείτε να μάθετε να κωδικοποιείτε εντελώς δωρεάν από πλατφόρμες όπως το freeCodeCamp, το Khan Academy, το YouTube και ούτω καθεξής. Έτσι, ακόμα κι αν δεν έχετε μεγάλο προϋπολογισμό, δεν χρειάζεται να ανησυχείτε για την απώλεια.

Μερίδιο Μερίδιο Τιτίβισμα ΗΛΕΚΤΡΟΝΙΚΗ ΔΙΕΥΘΥΝΣΗ Οι 7 καλύτεροι τρόποι για να μάθετε πώς να κωδικοποιείτε δωρεάν

Δεν μπορείτε να μάθετε να κωδικοποιείτε δωρεάν. Εκτός και αν δεν δώσετε σε αυτούς τους δοκιμασμένους πόρους, φυσικά.

Διαβάστε Επόμενο
Σχετικά θέματα
  • Προγραμματισμός
  • Πύθων
  • JavaScript
  • Φροντιστήρια κωδικοποίησης
Σχετικά με τον Συγγραφέα Γιουβράι Τσάντρα(Δημοσιεύθηκαν 60 άρθρα)

Ο Yuvraj είναι προπτυχιακός φοιτητής Πληροφορικής στο Πανεπιστήμιο του Δελχί, Ινδία. Είναι παθιασμένος με το Full Stack Web Development. Όταν δεν γράφει, εξερευνά το βάθος διαφορετικών τεχνολογιών.

Περισσότερα από τον Yuvraj Chandra

Εγγραφείτε στο newsletter μας

Εγγραφείτε στο ενημερωτικό μας δελτίο για τεχνικές συμβουλές, κριτικές, δωρεάν ebooks και αποκλειστικές προσφορές!

Κάντε κλικ εδώ για εγγραφή