Good Afternoon,
So yesterday I realized that I might have been completely vague and left a lot for misinterpretation. I will describe my program, show the code and then try to give an example of that I am trying to accomplish.
My Program:
I am trying to make an interactive program to get information on angles from the user (I am an artillery Training Instructor on Camp Pendleton and am trying to make some peoples lives much safer and easier). This program grabs numbers, either in (int) form or (double) form, I have created the formulas to convert their information into an Angle. After 5 difference calculation I finalize their equation by adding up all 5 angles to give them (the user) a very important and specific number to apply to their safety measurements.
My Code: (and critiques to syntax or format will be very helpful, I am very new to java)
/* This is going to be a skeleton program to produce * an application for calculating XO's Min QE within * a windows (toughbook) for Artillerymen or android platform smartphone/tablet * Written by: Sgt Morgan, Robert * Date Start: Oct 7, 2014 Date Finish: * Copywrite will be pending until finished */ import java.util.*; public class XoMinQe { public static void main(String[] args) { // ****Greeting and PREP**** System.out.print("Together we are going to "); System.out.println("calculate XO's Min QE.\n"); // going to have user press "enter" Scanner keyIn = new Scanner(System.in); System.out.println("Press the ENTER key to continue"); keyIn.nextLine(); // ****ANGLE 1**** // Declaring Angle 1 from user double angle1; // going to have user input followed by "enter" Scanner in = new Scanner(System.in); // This is going to get the total for Angle 1 System.out.print("Enter the Site to Crest information from the"); stem.out.println(" Section Chief Report and press Enter."); // Applying value from user to angleOne variable angle1 = in.nextDouble(); // Angle 1 round up *if required* System.out.println("The Value of Angle 1 is " + (int) Math.ceil(angle1)); int angleOne = (int) Math.ceil(angle1); System.out.println("\n"); //I do not know how to get proper spacing any other way // ****ANGLE 2**** // Getting the Vertical Clearance *Unarmed/Armed VT* from User System.out.print("What is the vertical clearance for your firing area?\n"); // Applying value from user to vertical clearance variable int verticalClearance = in.nextInt(); // Getting the PCR value from user System.out.print("\n What is the Piece to Crest Range (PCR) for that weapon?\n"); System.out.println("*Hint* You can get it from the Section Chief Report"); // Applying PCR to variable double pieceToCrestRange = in.nextDouble(); // Expressing PCR in thousandth double pcrExpression = (pieceToCrestRange / 1000); // Going to calculate vertclear/(pcr/1000) double angle2 = (verticalClearance / pcrExpression) * 1.0186; // Rounding up Angle 2 to final number System.out.println("\n The Value of Angle 2 is "+ (int) Math.ceil(angle2)); int angleTwo = (int) Math.ceil(angle2); // ****ANGLE 3**** // Getting the Site Factor = Angle 1 + Angle 2 int siteFactor = angleOne + angleTwo; // Declaring variable for Complementary Angle System.out.println("\n Enter the Complementary Angle from the TFT, Table G.\n"); double compAngle = in.nextDouble(); // Calculating for Angle 3 double angle3 = (siteFactor * compAngle); // Rounding up Angle 3 for final number System.out.println("The Value of Angle 3 is " + (int) Math.ceil(angle3)); int angleThree = (int) Math.ceil(angle3); System.out.println("\n"); //Same issue here with formatting // ****ANGLE 4**** // This is going to get value of Angle 4 from user System.out.println("What is the TFT Value for that Charge and PCR (TFT, Table F, Col. 2)?\n"); double tftValue = in.nextDouble(); // Rounding up Angle 4 for final number int angleFour = (int) Math.ceil(tftValue); System.out.println("The Value of Angle 4 is " + angleFour); // ****Angle 5**** // This is going to get the value for number of forks System.out.println("\n Enter the number of Forks (TFT, Table F)\n"); int forks = in.nextInt(); // Calculating for final result of Angle 5 int angleFive = (forks * 2); System.out.println("The Value of Angle 5 is " + angleFive); // Calculating End MIN QE for Gun ___ int minQE = (angleOne + angleTwo + angleThree + angleFour + angleFive); // ****MIN QE**** System.out.println("\n The MIN QE for this Gun is " + minQE); } }
Basic Concept of Look and Feel:
What I was hoping to learn was how to take this code and implement it into a user friendly which will expand as the answers are generated.
EXAMPLE:
Name: XO Min QE Calculator
My questions show up here from the above statements.(in the code)
Text Box------------------------- (Calculate)<---- Button
The Value of Angle 1 is ______
Each time the press a button a new "the vale of angle # _____ shows up extending the window until all 5 angles are computer and then finally showing the user their final product on the bottom of all the calculated data.
If anyone can help, I would appreciate it, if you cant or there is no way to do this please let me know. I am willing to clean up this code as much as possible as well. Any and all "lessons to be learned" will be greatly appreciated
*this is no homework, this is my own project to help my fellow Marines and Artillerymen alike.
Thank you