+ 1

I just wrote this code, is there a simplified way?

Calculating simple interest https://code.sololearn.com/cs0ptoe1O4MY/?ref=app

2nd Aug 2021, 10:18 AM
Ejeh Joseph
Ejeh Joseph - avatar
32 odpowiedzi
+ 5
Ejeh Joseph , nice code! just some comments from me: ▪︎before asking the first input, all input options should be shown: Options: - Simple Interest (si) - Principal (pr) - Time (ti) - Rate (ra) What do you want to calculate? - ▪︎there are only 4 inputs needed for the calculation, but each of them occurs multiple times as a code line. try to find a way without this duplicating. happy coding and good success!
2nd Aug 2021, 11:55 AM
Lothar
Lothar - avatar
+ 3
It's a simple equation. Do you know how to make a variable say x as the subject of the equation?
2nd Aug 2021, 10:53 AM
Allan 🔥STORMER🔥🔥🔥🔥
Allan 🔥STORMER🔥🔥🔥🔥 - avatar
+ 2
Allan 🔥STORMER🔥🔥🔥🔥 your code will also work fine here. But you need to provide input together line by line like 1000 10 2 It will output 200.00
2nd Aug 2021, 11:35 AM
sudhir meena
sudhir meena - avatar
+ 2
Ejeh Joseph Your Highness, I will do the needful when I get the Time 😉
3rd Aug 2021, 3:01 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
Try running this on computer, doesn't work well on sololearn app https://code.sololearn.com/caEe8zo23j3y/?ref=app
2nd Aug 2021, 10:49 AM
Allan 🔥STORMER🔥🔥🔥🔥
Allan 🔥STORMER🔥🔥🔥🔥 - avatar
+ 1
Thanks Lothar
2nd Aug 2021, 11:59 AM
Ejeh Joseph
Ejeh Joseph - avatar
+ 1
Ejeh Joseph there is no built in function in python to get SI directly as per my knowledge...but you can do less code to minimise your input and output part....like you can take all 3 inputs in once P,R,T = map(int, input().split()) Formula part and then output result = (P*R*T)/100 print(result)
2nd Aug 2021, 12:10 PM
sudhir meena
sudhir meena - avatar
+ 1
Ejeh Joseph what do you mean by unknown ...to get a SI you need to provide all three values P and R and T... either by giving constant values or take user input
2nd Aug 2021, 12:33 PM
sudhir meena
sudhir meena - avatar
+ 1
IMHO you can do this much faster by either : 1 Using functions in Python 2 Using client side JavaScript with alerts 📢 in an HTML page....
2nd Aug 2021, 10:15 PM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
Sanjay Kamath can you write the code in Python please
2nd Aug 2021, 10:17 PM
Ejeh Joseph
Ejeh Joseph - avatar
0
Allan 🔥STORMER🔥🔥🔥🔥 review my code again and see....it can also find the principal, time and rate
2nd Aug 2021, 10:53 AM
Ejeh Joseph
Ejeh Joseph - avatar
2nd Aug 2021, 10:58 AM
Ejeh Joseph
Ejeh Joseph - avatar
0
Do this, Since SI=(P*T*R) /100 Then make P the subject by cross multiplying like this SI*100= P*T*R Then divide both sides by T*R You will get P =( SI*100)/(T*R) Where P=Principle SI= Simple Interest T= Time R= Rate
2nd Aug 2021, 10:58 AM
Allan 🔥STORMER🔥🔥🔥🔥
Allan 🔥STORMER🔥🔥🔥🔥 - avatar
0
Allan 🔥STORMER🔥🔥🔥🔥 change of subject formula is not the problem... my question is if there is a simplified way of writing the code
2nd Aug 2021, 12:02 PM
Ejeh Joseph
Ejeh Joseph - avatar
0
sudhir meena thanks, but if I have SI, P, R and T is unknown... how to I do that... that's what I built!!... thanks once again
2nd Aug 2021, 12:30 PM
Ejeh Joseph
Ejeh Joseph - avatar
0
sudhir meena yes I know that. My question is what if you are given the simple, the principal, the rate and you are ask to find the time
2nd Aug 2021, 12:36 PM
Ejeh Joseph
Ejeh Joseph - avatar
0
Just a comment, the user don't know its the code for SI, so if you list all the options that if calculates, then user can give the right input except user want to calculate anything like add two numbers, anything like that.
3rd Aug 2021, 2:00 AM
Rojan Shrestha
Rojan Shrestha - avatar
0
Rojan Shrestha thanks I got that
3rd Aug 2021, 9:25 AM
Ejeh Joseph
Ejeh Joseph - avatar
0
Sanjay Kamath 😂😂 your highness?? Really?? ....
3rd Aug 2021, 9:26 AM
Ejeh Joseph
Ejeh Joseph - avatar
0
Can any one send me exact concepts of core java That are used in Intrview???
3rd Aug 2021, 1:26 PM
Ram. Rakesh vynala
Ram. Rakesh vynala - avatar