Genesis Garcia wrote: My problem is that I am supposed to separate all the calculations into a different class, but I am not fully aware of how to make that happen.
Here would be an easy way.
For example change this
to this. Make all you calculations methods in the class Calculations. Also -- note what happens if you enter a letter instead of a number. Never let something like that crash the program.
Make enums called Sex, VehicleType and VehicleBrand. Associate each constant with a multiplier. Make a Quote class that you instantiate with the age, sex, number of tickets, and the type and brand of the vehicle. All your main class has to do now is convert user input to strongly typed values, which you can use to create a Quote with. An instance of Quote can calculate its value in a compact method.
Float and double are like couches. They eat your loose change.
You can find more about big decimal here (read whole of thread because there are later additions) and (two shorter threads: 1 2). Remembering that 0.1D is slightly larger than 0.1, there is no chance of the loop I showed in link 2 running more than 10× (unless you try it out ).
They can spit out the change later, like in that loop which never runs more than 10×.
Stephan van Hulst wrote: . . . Float and double are like couches. They eat your loose change.
Shall we get back to the original subject of the thread?