Posts

Showing posts from August, 2022

Expansion Formulas in Java

Image
I was practising Maths and a thought came up to my mind that I should make a program in Java that could take the input in variables ‘a’ and ‘b’ and then it will ask the user which formulae of expansion they want to perform. Something like this. Currently, it has only 5 formulas because I am lazy to add more. Code I started with displaying the formulas this program can execute in the console System . out . println ( "Choose the Formula" ) ; System . out . println ( "Enter 1 for (a+b)^2" ) ; System . out . println ( "Enter 2 for (a-b)^2" ) ; System . out . println ( "Enter 3 for (a^2 - b^2)" ) ; System . out . println ( "Enter 4 for (a+b)^3" ) ; System . out . println ( "Enter 5 for (a-b)^3" ) ; So, this program will work for the following formulas: (a+b)² (a-b)² (a² - b²) (a+b)³ (a-b)³ I took the input of the choice in a variable ip (Don’t know why I chose this name 😅) which is o