My question is pretty simple. I have seen a lot of tutorials on how to "Make" A gui, that is. Put up buttons and a frame. I am still pretty confused on how you make stuff do things in it. Like how hard would it be to convert a program which is written and works in the dos frame to a GUI? Is it possible to slap on a gui after you program something or do you need to have it in mind all along? Im guessing you can create another program which will use the other programs logic, but just contains a gui. But i wouldnt know where to start with that.
Also, is there a good way to convert a .java/.class file to a executable file for windows?
For what its worth this is my code as of now. (for a comp sci/science fair project)
import java.util.Scanner;
import static java.lang.Math.*;
public class PhysicsCalc
{
static Scanner keyboard = new Scanner(System.in);
public static void main (String args[])
{
System.out.println("Physics Projection Calculator");
System.out.println("By Zachary Prinzbach");
System.out.println("");
menu();
}
public static void menu()
{
System.out.println("Please Pick one of the following calculations. Use the Number Keys to select.");
System.out.println("(1) Calculate X-Force and Y-Force from Angle and Total Force");
System.out.println("(2) Calculate instantanious Y velocity using Initial Y Vel. and Time");
System.out.println("(3) Calculate the distance traveled by an object before it hits the ground");
int choice = keyboard.nextInt();
if(choice == 1)
force();
else
{
if(choice == 2)
{
iYVel();
}
else
{
if(choice == 3)
{
xTravel();
}
}
}
}
public static void force()
{
System.out.println("Do you have (1) the total force and angle or (2) the X and Y Forces and angle?");
int choice = keyboard.nextInt();
if(choice == 1)
{
System.out.println("Please enter your angle");
double angle = keyboard.nextInt();
System.out.println("Please enter the total force");
double totalForce = keyboard.nextDouble();
double xForce = sin(angle) * totalForce;
double yForce = cos(angle) * totalForce;
System.out.println("The amount of X-Force is " + xForce + ".");
System.out.println("The amount of Y-Force is " + yForce + ".");
System.out.println("");
menu();
}
else
{
System.out.println("Please enter your angle");
double angle = keyboard.nextDouble();
System.out.println("Please enter the X force");
double xForce = keyboard.nextDouble();
System.out.println("Please enter the Y Force");
double yForce = keyboard.nextDouble();
double totalForce = xForce / sin(angle);
System.out.println("The Total force is " + totalForce + ".");
System.out.println("");
menu();
}
}
public static void iYVel()
{
System.out.println("Please enter the Initial Y Velocity.");
double yVelZero = keyboard.nextDouble();
System.out.println("Please enter an amount of time in seconds.");
double time = keyboard.nextDouble();
double iYVel = yVelZero / 9.8;
System.out.println("Your instantanious Y Velocity at " + time + " seconds is " + iYVel + ".");
System.out.println("");
menu();
}
public static void xTravel()
{
System.out.println("How high above ground is the object initially?");
double higth = keyboard.nextDouble();
System.out.println("Do you know the total Velocity? (1)-Yes (2)-No");
int choice = keyboard.nextInt();
if(choice == 1)
{
System.out.println("Please enter total Force.");
double tF = keyboard.nextDouble();
System.out.println("Please enter the angle of the force.");
double angle = keyboard.nextDouble();
double xDistance = ((tF * cos(angle)) / 9.81) + Math.sqrt(Math.pow(tF * sin(angle),2) + (19.6 * higth));
System.out.println("The object travels " + xDistance + " in the x direction before it hits the ground.");
menu();
}
else
{
System.out.println("Please enter your angle");
double angle = keyboard.nextDouble();
System.out.println("Please enter the X force");
double xForce = keyboard.nextDouble();
System.out.println("Please enter the Y Force");
double yForce = keyboard.nextDouble();
double tF = xForce / sin(angle);
System.out.println("The Total force is " + tF + ".");
System.out.println("");
double xDistance = ((tF * cos(angle)) / 9.81) + Math.sqrt(Math.pow(tF * sin(angle),2) + (19.6 * higth));
System.out.println("The object travels " + xDistance + " in the x direction before it hits the ground.");
menu();
}
}
}
Still going to add more to it but thats it as of now.

New Topic/Question
Reply



MultiQuote








|