Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //package dawson112.labexercises; // the folders which contain .java file wrt H:
- import javax.swing.JOptionPane; // required to use a JOptionPane for input from user
- /**
- * Here you put a short explanation of the purpose of your code.
- * This is a javadocs comment. Always have one of these comments in front of every
- * class and method. Use extra * before every line and indent for the comment to look nice!
- *
- * @author: your name
- * @version: date
- */
- // A class header. The class name is same as filename
- // A class is delimited by brace brackets
- public class Skeleton {
- // main method is required
- // Methods are also delimited by brace brackets
- public static void main(String[] args) {
- // Code within the main method is indented for readability.
- // You can also add blank lines for readability
- // Usually start by declaring any variables. Syntax is: type variableName;
- int number;
- String inputString; //used with JOptionPane for user input in text
- // Accepting number input with JOptionPane has two steps
- // 1- get the input into a string
- // 2- convert the string to the data type that you asked for
- inputString = JOptionPane.showInputDialog("Enter a whole number: ");
- number = Integer.parseInt(inputString);
- // Once you have all your input, do your calculations.
- // Display the results to the user.
- // Syntax is System.out.println("blah blah: "+ resultVariable);
- System.out.println("You entered: " + number);
- } // Brace to close the main method.
- // Braces should be aligned with the matching opening brace for readability
- } // Brace to close the class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement