Posted  by 

Trebuchet Calculator Program Java

Looks good for a beginner. Lamento beyond the void english free download. Couple tweaks if you want to make it look nicer.

  1. Calculator Program Java Code

The name of the class should be somewhat describing the purpose so in your case Calculator would fit better. If you are familiar with you could parse your +, -, / into an enum and do switch on that. Then next tweak could be to do the System.printout at the end and in the switch case to do just the operation. Another suggestion would be to make 4 classes implementing binary operations with just one method taking two arguments and returning the result. Then you can have a map with a key being the operation (in enum or string) and the value would be the appropriate class. Then you end up with more classes but this main method gets shorter.

Generally it is better to split the code in more methods and classes and keep the motto 'one class one responsibility',. So as an example each of your arithmetic classes would be responsible for a single arithmetic operation. Lotus organizer 97.

Trebuchet Calculator Program JavaCalculator

Calculator Program Java Code

If you want to follow that completely, then you would have to create a class that gets the input from the user as well. The Calculator class then would be just like a coordinator saying: give me numbers, give me an operator, perform the operation and print out the result at the end.

Simple calculator in Java. Import java.util.Scanner; public class Calculator. Program to check if a date is valid or not.

Note: If you want some sample code leave me a comment here and I can add some. Some points that can be improved: • As already mentioned by the others, you could extract the computation logic to separate methods. • You repeat System.out.println('Your answer is ' + [.]); several times in your code. Code repetition is bad. To fix it (if you want to keep the switch-case block), you could store the result of the computation into an integer variable and print the result after the switch-case block. • I personally don't declare the variables at the very beginning of the method. I declare them when I need them for the first time.

As a consequence, their scope is reduced. • You create a new scanner to ask the user for the operation type: Scanner op = new Scanner(System.in); Why? You can continue using scannerObject.

• I disagree with the advice of rolfl to close the resources in this case. I don't think System.inshould be closed. If you used both scanner objects ( scannerObject and op) and retrieved a value with op after having closed scannerObject you would end up with an exception!

Trebuchet Simulator To aid designers and enthusiasts (and anyone who wants to win a trebuchet competition), I created a trebuchet simulator, programmed in Microsoft Excel which simulates the motion of a trebuchet, and is very useful for trebuchet design. It captures all the essential. And if you wish to build a trebuchet yourself, this trebuchet software program allows you to optimize the dimensions of your trebuchet for maximum throwing distance, and also allows you to determine the required finger angle which results in the trebuchet releasing the payload at the right time, for maximum throwing distance. The required finger angle is based on the friction between the finger and ring. See the link above for an explanation of finger angle and ring. A user manual in PDF format is included with the Excel program.