I am getting multiple errors that I can't understand from JCreator LE. I am thinking about just making the program in C++ because these errors are getting annoying (the only reason I'm using Java is because I am in a java class right now).
Anyway, here is the source code:
CODE
/*Shoot For Your Grade
*Calculate horizontal distance for angle via the height and range
*/
public class shootcalculator
{
public static java.util.Scanner scanner = new java.util.Scanner(System.in);
public static void main(String args[])
{
// Get gravity
System.out.print("Enter gravity in m/s^2 (earth default is 9.8): ");
double gravityFactor = scanner.nextInt()/2;
// Get the initial height
System.out.print("\nInitial height of cannon (cm): ");
double height = scanner.nextInt();
// Get horizontal range
System.out.print("\nHorizontal range of cannon (cm): ");
double range = scanner.nextInt();
// Calculate time for payload to hit the ground
double time = (range/gravityFactor);
System.out.print("\nTime: " + time);
// Calculate muzzle velocity
double velocity = (range/time);
System.out.print("\nMuzzle Velocity: " + velocity);
// Get firing angle
double angle = scanner.nextInt();
// Calculate verticle and horizontal velocity
double horVel = velocity*asin(angle);
double verVel = velocity*acos(angle);
System.out.print("\nHorizontal Velocity: " + horVel);
System.out.print("\nVerticle Velocity: " + verVel);
// Calculate new time
double discr = Math.sqrt((velocity * velocity) - (4 * (gravity/(-2) * height));
System.out.print("\nDiscriminant: " + discr);
if ((velocity - discr) < 0)
double newTime = (velocity - discr)/2(gravity/(-2));
else
double newTime = (velocity + discr)/2(gravity/(-2));
System.out.print("\nNew Time: " + newTime);
// Calculate horizontal distance
double horDis = horVel*newTime+(gravity/-2)*pow(newTime, 2);
System.out.print("\nDISTANCE FIRED: " + horDis + "\nyay!");
}
}
*Calculate horizontal distance for angle via the height and range
*/
public class shootcalculator
{
public static java.util.Scanner scanner = new java.util.Scanner(System.in);
public static void main(String args[])
{
// Get gravity
System.out.print("Enter gravity in m/s^2 (earth default is 9.8): ");
double gravityFactor = scanner.nextInt()/2;
// Get the initial height
System.out.print("\nInitial height of cannon (cm): ");
double height = scanner.nextInt();
// Get horizontal range
System.out.print("\nHorizontal range of cannon (cm): ");
double range = scanner.nextInt();
// Calculate time for payload to hit the ground
double time = (range/gravityFactor);
System.out.print("\nTime: " + time);
// Calculate muzzle velocity
double velocity = (range/time);
System.out.print("\nMuzzle Velocity: " + velocity);
// Get firing angle
double angle = scanner.nextInt();
// Calculate verticle and horizontal velocity
double horVel = velocity*asin(angle);
double verVel = velocity*acos(angle);
System.out.print("\nHorizontal Velocity: " + horVel);
System.out.print("\nVerticle Velocity: " + verVel);
// Calculate new time
double discr = Math.sqrt((velocity * velocity) - (4 * (gravity/(-2) * height));
System.out.print("\nDiscriminant: " + discr);
if ((velocity - discr) < 0)
double newTime = (velocity - discr)/2(gravity/(-2));
else
double newTime = (velocity + discr)/2(gravity/(-2));
System.out.print("\nNew Time: " + newTime);
// Calculate horizontal distance
double horDis = horVel*newTime+(gravity/-2)*pow(newTime, 2);
System.out.print("\nDISTANCE FIRED: " + horDis + "\nyay!");
}
}
And here are the errors:
Click to view attachment
If anybody could help, it would be appreciated.