I just wrote this code, is there a simplified way? | Sololearn: Learn to code for FREE!

+1

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

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

8/2/2021 10:18:34 AM

Ejeh Joseph

32 Answers

New Answer

+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!

+3

It's a simple equation. Do you know how to make a variable say x as the subject of the equation?

+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

+2

Ejeh Joseph Your Highness, I will do the needful when I get the Time 😉

+1

Try running this on computer, doesn't work well on sololearn app https://code.sololearn.com/caEe8zo23j3y/?ref=app

+1

Thanks Lothar

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

+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

+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....

+1

Sanjay Kamath can you write the code in Python please

0

Allan 🔥STORMER🔥🔥🔥🔥 review my code again and see....it can also find the principal, time and rate

0

Allan 🔥STORMER🔥🔥🔥🔥 yes

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

0

Allan 🔥STORMER🔥🔥🔥🔥 change of subject formula is not the problem... my question is if there is a simplified way of writing the code

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

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

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.

0

Rojan Shrestha thanks I got that

0

Sanjay Kamath 😂😂 your highness?? Really?? ....

0

Can any one send me exact concepts of core java That are used in Intrview???