SlideShare a Scribd company logo
1 of 69
Download to read offline
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package finalproject;package finalproject;package finalproject;package finalproject;
import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;
import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;
public classpublic classpublic classpublic class Main {
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void main(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {
System.System.System.out.println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have "
+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");
System.System.System.out.println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything "
+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "
+ "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see.");
System.System.System.out.println();.println();.println();.println();.println();.println();
System.System.System.out.println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number "
+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "
+ "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter.");
System.System.System.out.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");
printMainMenu();
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void printMainMenu() {
Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in);
int choice;int choice;int choice;int choice;int choice;
boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter "
+ "it");+ "it");+ "it");+ "it");+ "it");+ "it");+ "it");+ "it");
System.System.System.out.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");
System.System.System.out.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");
System.System.System.out.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");
System.System.System.out.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");
System.System.System.out.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");
System.System.System.out.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");
System.System.System.out.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");
System.System.System.out.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");
System.System.System.out.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");
while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {
try {try {try {try {
choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();
if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {
Arithmetic.Arithmetic.Arithmetic.arithmeticMain();
} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {
FlowControl.FlowControl.FlowControl.flowControlMain();
} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {
Loops.Loops.Loops.loopsMain();
} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {
Methods.Methods.Methods.methodsMain();
} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Main.java
1.1 of 4 2014.12.04 18:55:26
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Operators.Operators.Operators.operatorsMain();
} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {
Variables.Variables.Variables.variablesMain();
} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {
IfElseStatements.IfElseStatements.IfElseStatements.ifElseMain();
} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {
Strings.Strings.Strings.stringMain();
} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {
System.System.System.exit(0);
}}
success = true;success = true;success = true;success = true;success = true;success = true;success = true;
} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");
System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");
System.System.System.out.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");
System.System.System.out.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");
System.System.System.out.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");
System.System.System.out.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");
System.System.System.out.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");
System.System.System.out.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");
System.System.System.out.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");
System.System.System.out.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");
System.System.System.out.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");
sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();
}}
}
}
}
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Main.java
2.1 of 4 2014.12.04 18:55:26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package finalproject;package finalproject;package finalproject;package finalproject;
import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;
import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;
public classpublic classpublic classpublic class Arithmetic {
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void arithmetic(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){
arithmeticMain();
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void arithmeticMain() {
//Variables are initiated//Variables are initiated
Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in);
int choice;int choice;int choice;int choice;int choice;
boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");
System.System.System.out.println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's "
+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");
//This println is used to sperate methods to make it easier to read//This println is used to sperate methods to make it easier to read
System.System.System.out.println();.println();.println();.println();.println();
//User is asked to choose an example to run//User is asked to choose an example to run
System.System.System.out.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");
System.System.System.out.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");
System.System.System.out.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");
System.System.System.out.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");
System.System.System.out.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");
System.System.System.out.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");
System.System.System.out.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");
System.System.System.out.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");
/* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a
method if the user inputs an incorrect value.method if the user inputs an incorrect value.
*/
while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {
// Initiates try-catch statement for exception// Initiates try-catch statement for exception
try {try {try {try {
/* User is given the choice of multiple methods that involve/* User is given the choice of multiple methods that involve/* User is given the choice of multiple methods that involve
ArithmenticsArithmentics
*/*/
choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();
if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {
addition();
} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {
subtraction();
} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {
multiplication();
} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {
division();
} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {
modulus();
} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java
1.1 of 18 2014.12.04 18:55:22
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {
Main.Main.Main.printMainMenu();
} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {
System.System.System.exit(0);
}}
success = true;success = true;success = true;success = true;success = true;success = true;success = true;
arithmeticMain();
/*Catch statement is used incase user inputs an invalid variable/*Catch statement is used incase user inputs an invalid variable/*Catch statement is used incase user inputs an invalid variable
and lets the user know the input is not allowed. Also reprintsand lets the user know the input is not allowed. Also reprints
the method choicesthe method choices
*/*/
} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");
System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read//read
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");
System.System.System.out.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");
System.System.System.out.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");
System.System.System.out.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");
System.System.System.out.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");
System.System.System.out.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");
System.System.System.out.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");
System.System.System.out.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");
sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();
}}
}
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void addition() {
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
int sum;int sum;int sum;int sum;int sum;
Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in);
boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;
/*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an
*invalid variable.*invalid variable.
*/*/
while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try {try {try {try {
System.System.System.out.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");
System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");
int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();
System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");
int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();
sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;
System.System.System.out.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);
//Sets successAddition to true so while loop ends//Sets successAddition to true so while loop ends
successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java
2.1 of 18 2014.12.04 18:55:22
successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;
/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables
*and lets the user know the input is not allowed.*and lets the user know the input is not allowed.
*/*/
} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {
System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read.//read.
System.System.System.out.println();.println();.println();.println();.println();
scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();
}}
}
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void subtraction() {
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
int result;int result;int result;int result;int result;
Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in);
boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;
/*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an
*invalid variable.*invalid variable.
*/*/
while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try {try {try {try {
System.System.System.out.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");
System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");
int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();
System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");
int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();
result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;
System.System.System.out.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);
//Sets successSubtraction to true so while loop ends//Sets successSubtraction to true so while loop ends
successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true;
/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables
*and lets the user know the input is not allowed.*and lets the user know the input is not allowed.
*/*/
} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {
System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read.//read.
System.System.System.out.println();.println();.println();.println();.println();
scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();
}}
}
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void multiplication() {
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
int result;int result;int result;int result;int result;
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java
3.1 of 18 2014.12.04 18:55:22
int result;int result;int result;int result;int result;
Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in);
boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;
/*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an
*invalid variable.*invalid variable.
*/*/
while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try {try {try {try {
System.System.System.out.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");
System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");
int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();
System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");
int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();
result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;
System.System.System.out.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);
//Sets successMultiplication to true so while loop ends//Sets successMultiplication to true so while loop ends
successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true;
/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables
*and lets the user know the input is not allowed.*and lets the user know the input is not allowed.
*/*/
} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {
System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read.//read.
System.System.System.out.println();.println();.println();.println();.println();
scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();
}}
}
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void division() {
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
//Variables are initiated//Variables are initiated
int result;int result;int result;int result;int result;
Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in);
boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;
/*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an
*invalid variable.*invalid variable.
*/*/
while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try {try {try {try {
System.System.System.out.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");
System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");
int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();
System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");
int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();
result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;
System.System.System.out.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);
//Sets successDivision to true so while loop ends//Sets successDivision to true so while loop ends
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java
4.1 of 18 2014.12.04 18:55:22
//Sets successDivision to true so while loop ends//Sets successDivision to true so while loop ends
successDivision = true;successDivision = true;successDivision = true;successDivision = true;successDivision = true;successDivision = true;successDivision = true;
/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables
*and lets the user know the input is not allowed.*and lets the user know the input is not allowed.
*/*/
} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {
System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read.//read.
System.System.System.out.println();.println();.println();.println();.println();
scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();
}}
}
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void modulus() {
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
//Variables are initiated//Variables are initiated
int result;int result;int result;int result;int result;
Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in);
boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;
/*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an
*invalid variable.*invalid variable.
*/*/
while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try {try {try {try {
System.System.System.out.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");
System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");
int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();
System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");
int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();
result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;
System.System.System.out.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);
//Sets successModulus to true so while loop ends//Sets successModulus to true so while loop ends
successModulus = true;successModulus = true;successModulus = true;successModulus = true;successModulus = true;successModulus = true;successModulus = true;
/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables
*and lets the user know the input is not allowed.*and lets the user know the input is not allowed.
*/*/
} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {
System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read.//read.
System.System.System.out.println();.println();.println();.println();.println();
scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();
}}
}
}
}
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java
5.1 of 18 2014.12.04 18:55:22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package finalproject;package finalproject;package finalproject;package finalproject;
import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;
import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;
public classpublic classpublic classpublic class FlowControl {
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void flowControl(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){
flowControlMain();
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void flowControlMain() {
Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in);
int choice;int choice;int choice;int choice;int choice;
boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");
System.System.System.out.println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have "
+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");
System.System.System.out.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");
System.System.System.out.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");
System.System.System.out.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");
/* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a
* Method if he or she inputs a incorrect value.* Method if he or she inputs a incorrect value.* Method if he or she inputs a incorrect value.
*/*/
while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try {try {try {try {
/* User is given the choice of different methods that/* User is given the choice of different methods that
* explain how flow control is handled in Java.* explain how flow control is handled in Java.
*/*/
choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();
if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {
sleepExample();
} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {
Main.Main.Main.printMainMenu();
} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {
System.System.System.exit(0);
}}
//Sets success to true so while loop ends//Sets success to true so while loop ends
success = true;success = true;success = true;success = true;success = true;success = true;success = true;
flowControlMain();
/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables
*and lets the user know the input is not allowed. Reprints the*and lets the user know the input is not allowed. Reprints the
*example choices.*example choices.
*/*/
} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/FlowControl.java
1.1 of 6 2014.12.04 18:55:24
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");
System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read.//read.
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");
System.System.System.out.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");
System.System.System.out.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");
System.System.System.out.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");
sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();
}}
}
}
//Method uses boolean to determine whether the user can sleep in or not.//Method uses boolean to determine whether the user can sleep in or not.
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void sleepExample() {
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in);
boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;
/*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an
*invalid variable.*invalid variable.
*/*/
while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try {try {try {try {
//User friendly explaination//User friendly explaination
System.System.System.out.println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can "
+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "
+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");
//User is asked whether today is a weekday or not.//User is asked whether today is a weekday or not.
System.System.System.out.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");
boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();
//User is asked whether he or she is on vacation.//User is asked whether he or she is on vacation.
System.System.System.out.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");
boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();
System.System.System.out.println();.println();.println();.println();.println();
//If true, user can sleep in.//If true, user can sleep in.
if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {
System.System.System.out.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");
System.System.System.out.println();.println();.println();.println();.println();
//If false, user cannot sleep in//If false, user cannot sleep in
} else {} else {} else {} else {} else {} else {
System.System.System.out.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");
System.System.System.out.println();.println();.println();.println();.println();
}}
//Sets successSE to true so while loop ends//Sets successSE to true so while loop ends
successSE = true;successSE = true;successSE = true;successSE = true;successSE = true;successSE = true;successSE = true;
/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables
*and lets the user know the input is not allowed.*and lets the user know the input is not allowed.
*/*/
} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/FlowControl.java
2.1 of 6 2014.12.04 18:55:24
102
103
104
105
106
107
108
109
110
111
112
113
114
} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {
System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");
System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");
//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to
//read.//read.
System.System.System.out.println();.println();.println();.println();.println();
scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();
}}
}
}
}
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/FlowControl.java
3.1 of 6 2014.12.04 18:55:24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package finalproject;package finalproject;package finalproject;package finalproject;
import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;
import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;
public classpublic classpublic classpublic class Loops {
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void loops(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){
loopsMain();
}
public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void loopsMain(){
//Variables are initiated//Variables are initiated
Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in);
int choice;int choice;int choice;int choice;int choice;
boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");
System.System.System.out.println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a "
+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "
+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "
+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");
//This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read.
System.System.System.out.println();.println();.println();.println();.println();
System.System.System.out.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");
System.System.System.out.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");
System.System.System.out.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");
System.System.System.out.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");
System.System.System.out.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");
System.System.System.out.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");
/*While loop is used to allow the user to re-enter the value for a/*While loop is used to allow the user to re-enter the value for a/*While loop is used to allow the user to re-enter the value for a
method if the user inputs an incorrect valuemethod if the user inputs an incorrect value
*/
while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){
//Initiates try-catch statement for exception//Initiates try-catch statement for exception
try{try{try{
/*User is given the choice of multiple methods that involve/*User is given the choice of multiple methods that involve
loopsloops
*/*/
choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();
if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {
forLoop();
} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {
whileLoop();
} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {
doWhileLoop();
} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {
Main.Main.Main.printMainMenu();
} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {
System.System.System.exit(0);
}}
//Sets successLoopsMain to true so while loop ends//Sets successLoopsMain to true so while loop ends
C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Loops.java
1.1 of 10 2014.12.04 18:55:26
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project
Final Project

More Related Content

What's hot

QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory archana singh
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingPathomchon Sriwilairit
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36ecomputernotes
 
Recentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissancesRecentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissancesMathieu d'Aquin
 
[Curso Java Basico] Aula 59: Importacao estatica (static import)
[Curso Java Basico] Aula 59: Importacao estatica (static import)[Curso Java Basico] Aula 59: Importacao estatica (static import)
[Curso Java Basico] Aula 59: Importacao estatica (static import)Loiane Groner
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner codeMite Mitreski
 
Python Peculiarities
Python PeculiaritiesPython Peculiarities
Python Peculiaritiesnoamt
 

What's hot (9)

QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
 
Recentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissancesRecentrer l'intelligence artificielle sur les connaissances
Recentrer l'intelligence artificielle sur les connaissances
 
[Curso Java Basico] Aula 59: Importacao estatica (static import)
[Curso Java Basico] Aula 59: Importacao estatica (static import)[Curso Java Basico] Aula 59: Importacao estatica (static import)
[Curso Java Basico] Aula 59: Importacao estatica (static import)
 
Ann
AnnAnn
Ann
 
Exceptional exceptions
Exceptional exceptionsExceptional exceptions
Exceptional exceptions
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner code
 
Python Peculiarities
Python PeculiaritiesPython Peculiarities
Python Peculiarities
 

Similar to Final Project

ch04-conditional-execution.ppt
ch04-conditional-execution.pptch04-conditional-execution.ppt
ch04-conditional-execution.pptMahyuddin8
 
Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3DanWooster1
 
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfRepeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfarracollection
 
Forecasting using data - Deliver 2016
Forecasting using data  - Deliver 2016Forecasting using data  - Deliver 2016
Forecasting using data - Deliver 2016Troy Magennis
 
conditional statements
conditional statementsconditional statements
conditional statementsJames Brotsos
 
Im having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdfIm having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdfstopgolook
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdfICADCMLTPC
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
 
02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LABHari Christian
 
Clean code with google guava jee conf
Clean code with google guava jee confClean code with google guava jee conf
Clean code with google guava jee confIgor Anishchenko
 
About java
About javaAbout java
About javaJay Xu
 
TASK #1In the domain class you will create a loop that will prompt.pdf
TASK #1In the domain class you will create a loop that will prompt.pdfTASK #1In the domain class you will create a loop that will prompt.pdf
TASK #1In the domain class you will create a loop that will prompt.pdfindiaartz
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfShashikantSathe3
 

Similar to Final Project (20)

201707 CSE110 Lecture 13
201707 CSE110 Lecture 13   201707 CSE110 Lecture 13
201707 CSE110 Lecture 13
 
Core java
Core javaCore java
Core java
 
ch04-conditional-execution.ppt
ch04-conditional-execution.pptch04-conditional-execution.ppt
ch04-conditional-execution.ppt
 
Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3Java Chapter 05 - Conditions & Loops: part 3
Java Chapter 05 - Conditions & Loops: part 3
 
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfRepeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
 
Forecasting using data - Deliver 2016
Forecasting using data  - Deliver 2016Forecasting using data  - Deliver 2016
Forecasting using data - Deliver 2016
 
conditional statements
conditional statementsconditional statements
conditional statements
 
02 - Prepcode
02 - Prepcode02 - Prepcode
02 - Prepcode
 
Im having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdfIm having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdf
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
 
Comp102 lec 6
Comp102   lec 6Comp102   lec 6
Comp102 lec 6
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB
 
Clean code with google guava jee conf
Clean code with google guava jee confClean code with google guava jee conf
Clean code with google guava jee conf
 
About java
About javaAbout java
About java
 
130706266060138191
130706266060138191130706266060138191
130706266060138191
 
TASK #1In the domain class you will create a loop that will prompt.pdf
TASK #1In the domain class you will create a loop that will prompt.pdfTASK #1In the domain class you will create a loop that will prompt.pdf
TASK #1In the domain class you will create a loop that will prompt.pdf
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
 
Comp102 lec 5.1
Comp102   lec 5.1Comp102   lec 5.1
Comp102 lec 5.1
 
Lazy Java
Lazy JavaLazy Java
Lazy Java
 

Final Project

  • 1. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 package finalproject;package finalproject;package finalproject;package finalproject; import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException; import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner; public classpublic classpublic classpublic class Main { public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void main(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) {(String[] args) { System.System.System.out.println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have ".println("This Program was written using examples I have " + "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester.");+ "learned throughout the entire semester."); System.System.System.out.println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything ".println("To make things easier to understand, everything " + "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able "+ "was seperated into 7 different sections that you are able " + "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see.");+ "to see."); System.System.System.out.println();.println();.println();.println();.println();.println(); System.System.System.out.println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number ".println("You'll be nagviating by entering the number " + "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing "+ "associtated with the section or example and pressing " + "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter.");+ "enter."); System.System.System.out.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin.");.println("Now let us begin."); printMainMenu(); } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void printMainMenu() { Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in); int choice;int choice;int choice;int choice;int choice; boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false; //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter ".println("This is the main menu, choose a section to enter " + "it");+ "it");+ "it");+ "it");+ "it");+ "it");+ "it");+ "it"); System.System.System.out.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic"); System.System.System.out.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control"); System.System.System.out.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops"); System.System.System.out.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods"); System.System.System.out.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators"); System.System.System.out.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables"); System.System.System.out.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements"); System.System.System.out.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings"); System.System.System.out.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit"); while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) { try {try {try {try { choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt(); if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) { Arithmetic.Arithmetic.Arithmetic.arithmeticMain(); } else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) { FlowControl.FlowControl.FlowControl.flowControlMain(); } else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) { Loops.Loops.Loops.loopsMain(); } else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) { Methods.Methods.Methods.methodsMain(); } else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) { C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Main.java 1.1 of 4 2014.12.04 18:55:26
  • 2. 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 Operators.Operators.Operators.operatorsMain(); } else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) { Variables.Variables.Variables.variablesMain(); } else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) { IfElseStatements.IfElseStatements.IfElseStatements.ifElseMain(); } else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) {} else if (choice == 8) { Strings.Strings.Strings.stringMain(); } else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) {} else if (choice == 9) { System.System.System.exit(0); }} success = true;success = true;success = true;success = true;success = true;success = true;success = true; } catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) {} catch (InputMismatchException ePrintMainMenu) { System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!"); System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again"); System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section");.println("Choose a Section"); System.System.System.out.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic");.println("1. Arithmetic"); System.System.System.out.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control");.println("2. Flow Control"); System.System.System.out.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops");.println("3. Loops"); System.System.System.out.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods");.println("4. Methods"); System.System.System.out.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators");.println("5. Operators"); System.System.System.out.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables");.println("6. Variables"); System.System.System.out.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements");.println("7. If Else Statements"); System.System.System.out.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings");.println("8. Strings"); System.System.System.out.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit");.println("9. Quit"); sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();sc.next(); }} } } } C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Main.java 2.1 of 4 2014.12.04 18:55:26
  • 3.
  • 4. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 package finalproject;package finalproject;package finalproject;package finalproject; import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException; import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner; public classpublic classpublic classpublic class Arithmetic { public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void arithmetic(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){ arithmeticMain(); } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void arithmeticMain() { //Variables are initiated//Variables are initiated Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in); int choice;int choice;int choice;int choice;int choice; boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false; System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section");.println("You have selected the Arithmetics Section"); System.System.System.out.println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's ".println("Arithemtic is pretty self explanatory, it's " + "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program.");+ "math used within a program."); //This println is used to sperate methods to make it easier to read//This println is used to sperate methods to make it easier to read System.System.System.out.println();.println();.println();.println();.println(); //User is asked to choose an example to run//User is asked to choose an example to run System.System.System.out.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example"); System.System.System.out.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition"); System.System.System.out.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction"); System.System.System.out.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication"); System.System.System.out.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division"); System.System.System.out.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus"); System.System.System.out.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu"); System.System.System.out.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit"); /* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a method if the user inputs an incorrect value.method if the user inputs an incorrect value. */ while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) { // Initiates try-catch statement for exception// Initiates try-catch statement for exception try {try {try {try { /* User is given the choice of multiple methods that involve/* User is given the choice of multiple methods that involve/* User is given the choice of multiple methods that involve ArithmenticsArithmentics */*/ choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt(); if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) { addition(); } else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) { subtraction(); } else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) { multiplication(); } else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) { division(); } else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) { modulus(); } else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) { C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java 1.1 of 18 2014.12.04 18:55:22
  • 5.
  • 6. 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 } else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) {} else if (choice == 6) { Main.Main.Main.printMainMenu(); } else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) {} else if (choice == 7) { System.System.System.exit(0); }} success = true;success = true;success = true;success = true;success = true;success = true;success = true; arithmeticMain(); /*Catch statement is used incase user inputs an invalid variable/*Catch statement is used incase user inputs an invalid variable/*Catch statement is used incase user inputs an invalid variable and lets the user know the input is not allowed. Also reprintsand lets the user know the input is not allowed. Also reprints the method choicesthe method choices */*/ } catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) {} catch (InputMismatchException eArithmeticMain) { System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that");.println("You can't do that"); System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read//read System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example");.println("Choose a Arithmetic Example"); System.System.System.out.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition");.println("1. Addition"); System.System.System.out.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction");.println("2. Subtraction"); System.System.System.out.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication");.println("3. Multiplication"); System.System.System.out.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division");.println("4. Division"); System.System.System.out.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus");.println("5. Modulus"); System.System.System.out.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu");.println("6. Main Menu"); System.System.System.out.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit");.println("7. Quit"); sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();sc.next(); }} } } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void addition() { //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); int sum;int sum;int sum;int sum;int sum; Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in); boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false;boolean successAddition = false; /*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an *invalid variable.*invalid variable. */*/ while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) {while (!successAddition) { //Initiates try-catch statement for exception//Initiates try-catch statement for exception try {try {try {try { System.System.System.out.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example.");.println("This is a simple addition example."); System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: "); int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt(); System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: "); int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt(); sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2;sum = num1 + num2; System.System.System.out.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum);.println("The sum is: " + sum); //Sets successAddition to true so while loop ends//Sets successAddition to true so while loop ends successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true; C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java 2.1 of 18 2014.12.04 18:55:22
  • 7.
  • 8. successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true;successAddition = true; /*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables *and lets the user know the input is not allowed.*and lets the user know the input is not allowed. */*/ } catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) {} catch (InputMismatchException eAddition) { System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read.//read. System.System.System.out.println();.println();.println();.println();.println(); scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next(); }} } } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void subtraction() { //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); int result;int result;int result;int result;int result; Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in); boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false;boolean successSubtraction = false; /*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an *invalid variable.*invalid variable. */*/ while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) {while (!successSubtraction) { //Initiates try-catch statement for exception//Initiates try-catch statement for exception try {try {try {try { System.System.System.out.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example.");.println("This is a simple subtraction example."); System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: "); int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt(); System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: "); int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt(); result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2;result = num1 - num2; System.System.System.out.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result); //Sets successSubtraction to true so while loop ends//Sets successSubtraction to true so while loop ends successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true;successSubtraction = true; /*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables *and lets the user know the input is not allowed.*and lets the user know the input is not allowed. */*/ } catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) {} catch (InputMismatchException eSubtraction) { System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read.//read. System.System.System.out.println();.println();.println();.println();.println(); scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next(); }} } } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void multiplication() { //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); int result;int result;int result;int result;int result; C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java 3.1 of 18 2014.12.04 18:55:22
  • 9.
  • 10. int result;int result;int result;int result;int result; Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in); boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false;boolean successMultiplication = false; /*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an *invalid variable.*invalid variable. */*/ while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) {while (!successMultiplication) { //Initiates try-catch statement for exception//Initiates try-catch statement for exception try {try {try {try { System.System.System.out.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example.");.println("This is a simple multiplication example."); System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: "); int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt(); System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: "); int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt(); result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2;result = num1 * num2; System.System.System.out.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result);.println("The product is: " + result); //Sets successMultiplication to true so while loop ends//Sets successMultiplication to true so while loop ends successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true;successMultiplication = true; /*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables *and lets the user know the input is not allowed.*and lets the user know the input is not allowed. */*/ } catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) {} catch (InputMismatchException eMultiplication) { System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read.//read. System.System.System.out.println();.println();.println();.println();.println(); scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next(); }} } } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void division() { //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); //Variables are initiated//Variables are initiated int result;int result;int result;int result;int result; Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in); boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false;boolean successDivision = false; /*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an *invalid variable.*invalid variable. */*/ while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) {while (!successDivision) { //Initiates try-catch statement for exception//Initiates try-catch statement for exception try {try {try {try { System.System.System.out.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example.");.println("This is a simple division example."); System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: "); int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt(); System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: "); int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt(); result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2;result = num1 / num2; System.System.System.out.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result); //Sets successDivision to true so while loop ends//Sets successDivision to true so while loop ends C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java 4.1 of 18 2014.12.04 18:55:22
  • 11.
  • 12. //Sets successDivision to true so while loop ends//Sets successDivision to true so while loop ends successDivision = true;successDivision = true;successDivision = true;successDivision = true;successDivision = true;successDivision = true;successDivision = true; /*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables *and lets the user know the input is not allowed.*and lets the user know the input is not allowed. */*/ } catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) {} catch (InputMismatchException eDivision) { System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read.//read. System.System.System.out.println();.println();.println();.println();.println(); scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next(); }} } } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void modulus() { //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); //Variables are initiated//Variables are initiated int result;int result;int result;int result;int result; Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in); boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false;boolean successModulus = false; /*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an *invalid variable.*invalid variable. */*/ while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) {while (!successModulus) { //Initiates try-catch statement for exception//Initiates try-catch statement for exception try {try {try {try { System.System.System.out.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example.");.println("This is a simple modulus example."); System.System.System.out.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: ");.print("Enter a Integer: "); int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt();int num1 = scanner.nextInt(); System.System.System.out.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: ");.print("Enter another Integer: "); int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt();int num2 = scanner.nextInt(); result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2;result = num1 % num2; System.System.System.out.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result);.println("The result is: " + result); //Sets successModulus to true so while loop ends//Sets successModulus to true so while loop ends successModulus = true;successModulus = true;successModulus = true;successModulus = true;successModulus = true;successModulus = true;successModulus = true; /*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables *and lets the user know the input is not allowed.*and lets the user know the input is not allowed. */*/ } catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) {} catch (InputMismatchException eModulus) { System.System.System.out.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable");.println("Wrong Variable"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read.//read. System.System.System.out.println();.println();.println();.println();.println(); scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next(); }} } } } C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Arithmetic.java 5.1 of 18 2014.12.04 18:55:22
  • 13.
  • 14. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 package finalproject;package finalproject;package finalproject;package finalproject; import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException; import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner; public classpublic classpublic classpublic class FlowControl { public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void flowControl(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){ flowControlMain(); } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void flowControlMain() { Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in); int choice;int choice;int choice;int choice;int choice; boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false;boolean success = false; System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section");.println("You have selected the Flow Control Section"); System.System.System.out.println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have ".println("Flow Control is used if one actions can have " + "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens.");+ "multiple outcomes depending on what happens."); //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example"); System.System.System.out.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep"); System.System.System.out.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu"); System.System.System.out.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit"); /* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a/* While loop is used to allow the user to re-enter the value for a * Method if he or she inputs a incorrect value.* Method if he or she inputs a incorrect value.* Method if he or she inputs a incorrect value. */*/ while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) {while (!success) { //Initiates try-catch statement for exception//Initiates try-catch statement for exception try {try {try {try { /* User is given the choice of different methods that/* User is given the choice of different methods that * explain how flow control is handled in Java.* explain how flow control is handled in Java. */*/ choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt(); if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) { sleepExample(); } else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) { Main.Main.Main.printMainMenu(); } else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) { System.System.System.exit(0); }} //Sets success to true so while loop ends//Sets success to true so while loop ends success = true;success = true;success = true;success = true;success = true;success = true;success = true; flowControlMain(); /*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables *and lets the user know the input is not allowed. Reprints the*and lets the user know the input is not allowed. Reprints the *example choices.*example choices. */*/ } catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) {} catch (InputMismatchException eFlowControlMain) { System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!"); C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/FlowControl.java 1.1 of 6 2014.12.04 18:55:24
  • 15.
  • 16. 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!"); System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read.//read. System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example");.println("Choose a Flow Control Example"); System.System.System.out.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep");.println("1. Sleep"); System.System.System.out.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu");.println("2. Main Menu"); System.System.System.out.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit");.println("3. Quit"); sc.next();sc.next();sc.next();sc.next();sc.next();sc.next();sc.next(); }} } } //Method uses boolean to determine whether the user can sleep in or not.//Method uses boolean to determine whether the user can sleep in or not. public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void sleepExample() { //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.Scanner scanner = new Scanner(System.in); boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false;boolean successSE = false; /*While loop is set up to reprint the method incase user inputs an/*While loop is set up to reprint the method incase user inputs an *invalid variable.*invalid variable. */*/ while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) {while (!successSE) { //Initiates try-catch statement for exception//Initiates try-catch statement for exception try {try {try {try { //User friendly explaination//User friendly explaination System.System.System.out.println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can ".println("The user is asks whether he or she can " + "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or "+ "sleep in based on whether it is a weekday and/or " + "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation.");+ "he or she is on vacation."); //User is asked whether today is a weekday or not.//User is asked whether today is a weekday or not. System.System.System.out.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): ");.print("Is it a weekday today?(true or false): "); boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean();boolean w = scanner.nextBoolean(); //User is asked whether he or she is on vacation.//User is asked whether he or she is on vacation. System.System.System.out.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): ");.print("Are you on vacation?(true or false): "); boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean();boolean v = scanner.nextBoolean(); System.System.System.out.println();.println();.println();.println();.println(); //If true, user can sleep in.//If true, user can sleep in. if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) {if (w == true && v == true) { System.System.System.out.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D");.println("You can sleep in! :D"); System.System.System.out.println();.println();.println();.println();.println(); //If false, user cannot sleep in//If false, user cannot sleep in } else {} else {} else {} else {} else {} else { System.System.System.out.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :(");.println("You cannot sleep in. :("); System.System.System.out.println();.println();.println();.println();.println(); }} //Sets successSE to true so while loop ends//Sets successSE to true so while loop ends successSE = true;successSE = true;successSE = true;successSE = true;successSE = true;successSE = true;successSE = true; /*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables/*Catch statement is used incase user inputs invalid variables *and lets the user know the input is not allowed.*and lets the user know the input is not allowed. */*/ } catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) { C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/FlowControl.java 2.1 of 6 2014.12.04 18:55:24
  • 17.
  • 18. 102 103 104 105 106 107 108 109 110 111 112 113 114 } catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) {} catch (InputMismatchException eSleepExample) { System.System.System.out.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!");.println("You can't do that!"); System.System.System.out.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again");.println("Try Again"); //This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to//This println is used to sperate methods to make it easier to //read.//read. System.System.System.out.println();.println();.println();.println();.println(); scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next();scanner.next(); }} } } } C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/FlowControl.java 3.1 of 6 2014.12.04 18:55:24
  • 19. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 package finalproject;package finalproject;package finalproject;package finalproject; import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException;import java.util.InputMismatchException; import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner;import java.util.Scanner; public classpublic classpublic classpublic class Loops { public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void loops(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){(String[] args){ loopsMain(); } public static voidpublic static voidpublic static voidpublic static voidpublic static voidpublic static void loopsMain(){ //Variables are initiated//Variables are initiated Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.Scanner sc = new Scanner(System.in); int choice;int choice;int choice;int choice;int choice; boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false;boolean successLoopsMain = false; System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section");.println("You have selected the Loops Section"); System.System.System.out.println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a ".println("Loops are used to to repeat actions within a " + "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, "+ "program. They can be use in conjunction with exceptions, " + "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to "+ "exceptions being try-catch statements that are used to " + "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing.");+ "prevent the program from crashing."); //This println is used to sperate methods to make it easier to read.//This println is used to sperate methods to make it easier to read. System.System.System.out.println();.println();.println();.println();.println(); System.System.System.out.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example");.println("Choose a Loop Example"); System.System.System.out.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop");.println("1. For Loop"); System.System.System.out.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop");.println("2. While Loop"); System.System.System.out.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop");.println("3. Do Loop"); System.System.System.out.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu");.println("4. Main Menu"); System.System.System.out.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit");.println("5. Quit"); /*While loop is used to allow the user to re-enter the value for a/*While loop is used to allow the user to re-enter the value for a/*While loop is used to allow the user to re-enter the value for a method if the user inputs an incorrect valuemethod if the user inputs an incorrect value */ while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){while (!successLoopsMain){ //Initiates try-catch statement for exception//Initiates try-catch statement for exception try{try{try{ /*User is given the choice of multiple methods that involve/*User is given the choice of multiple methods that involve loopsloops */*/ choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt();choice = sc.nextInt(); if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) {if (choice == 1) { forLoop(); } else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) {} else if (choice == 2) { whileLoop(); } else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) {} else if (choice == 3) { doWhileLoop(); } else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) {} else if (choice == 4) { Main.Main.Main.printMainMenu(); } else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) {} else if (choice == 5) { System.System.System.exit(0); }} //Sets successLoopsMain to true so while loop ends//Sets successLoopsMain to true so while loop ends C:/Users/Mike/Documents/NetBeansProjects/FinalProject/src/finalproject/Loops.java 1.1 of 10 2014.12.04 18:55:26