I am working on a program for one of my classes, and it contains a simple menu like this:
Please choose an option below:
--------------------------------
1) Calculate with just gravity
2) Calculate with net force
3) Calculate with just drag
Now, usually it would be quite simple to determine what the menu choice is, but we are not allowed to use logical operators, relational operators, or selection constructs. I've been trying to use modulus, but to no avail. Is this even possible? We essentially can only use +, -, *, /, and %. As well as simple variables. Thank you!
I assume net force = gravity + drag, and input is one of 1, 2, or 3.
net_force = gravity + drag
result = (2 - choice) * gravity + net_force + (choice - 2) * drag
result = result / (choice % 2 + 1)
All of +-*/%
are used .
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments