Question: Hello, how to ask for inputs again after the program terminate? it doesn't ask for the angle input to restart after the system terminate? How
Hello,
how to ask for inputs again after the program terminate? it doesn't ask for the angle input to restart after the system terminate? How to fix it? this is java
I want it to terminate first then restart
if (error < 0) { if (launchAngle == 45) { JOptionPane.showMessageDialog(null, "Target is too far! Restart the program with greater initial velocity!", "Modification needed", JOptionPane.WARNING_MESSAGE); System.out.println("Target is too far!\ Restart the program with greater initial velocity!"); } else { JOptionPane.showMessageDialog(null, "Restart the program with greater initial angle as 45!", "Modification needed", JOptionPane.WARNING_MESSAGE); } System.exit(0); angleInput = JOptionPane.showInputDialog("Enter the launch angle in degrees:"); flightTime = 2 * initialVelocity * Math.sin(radian) / GRAVITATION; flighttimeDivided = flightTime / 2; highestPoint = (initialVelocity * Math.sin(radian)) * flighttimeDivided - (double) 1 / 2 * (GRAVITATION * Math.pow(flighttimeDivided, 2));// not 94.53 distanceTraveled = (initialVelocity * Math.cos(radian)) * flightTime; error = distanceTraveled - distanceToTarget; minError = Math.abs(error); trajectory = String.format( "initial velocity: %.1f feet/sec launch angle: %.1f degrees flight time: %.2f seconds maximum height: %.2f feet distance traveled: %.2f feet target missed: %.2f feet", initialVelocity, launchAngle, flightTime, highestPoint, distanceTraveled, error); title = "Trajectory data report"; JOptionPane.showMessageDialog(null, trajectory, title, JOptionPane.INFORMATION_MESSAGE); trajectory = String.format( "initial velocity: %.1f feet/sec launch angle: %.1f degrees flight time: %.2f seconds maximum height: %.2f feet distance traveled: %.2f feet target missed: %.2f feet", initialVelocity, launchAngle, flightTime, highestPoint, distanceTraveled, error); System.out.println(trajectory);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
