This document contains code for a Java program that acts as a menu-driven tutorial on various Java topics. It presents the user with a main menu of 9 options corresponding to different sections of the tutorial like arithmetic, loops, and strings. The user can enter a number to select a section to learn about. The program uses conditionals and methods to direct the user to the appropriate section code based on their input selection. It is intended to help users learn Java concepts in an organized, modular way through interactive examples and exercises.
http://www.javaassignmenthelp.net/5-most-popular-java-problems-and-solutions/ Are you looking for Java problems and their solutions? You can find it at the link provided
We aren't sure about you, but working with Java 8 made one of the speakers lose all of his hair and the other lose his sleep (or was it the jetlag?). If you still haven't reached the level of Brian Goetz in mastering lambdas and strings, this talk is for you. And if you think you have, we have some bad news for you, you should attend as well.
http://www.javaassignmenthelp.net/5-most-popular-java-problems-and-solutions/ Are you looking for Java problems and their solutions? You can find it at the link provided
We aren't sure about you, but working with Java 8 made one of the speakers lose all of his hair and the other lose his sleep (or was it the jetlag?). If you still haven't reached the level of Brian Goetz in mastering lambdas and strings, this talk is for you. And if you think you have, we have some bad news for you, you should attend as well.
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfarracollection
Repeat Programming Project 2 in Chapter 5. This time, add the following four constructor
methods: one for each instance variable, one with two parameters for the two instance variables,
and a default constructor. Be sure that each constructor sets all the instance variables. write a
driver program to test each of the methods, including each of the four constructors and at least
one true or false case for each of the test method.
this is the code that i have to add four constructor methods to
import java.util.*;
public class PersonImproved// Counter is the name of the class and i saved it in a file named
PersonImproved.
{
//Data members
private String name;
private int age;
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println(\"What is the person\'s name?\");// This gets the program ready for
keyboard input by telling us that there is a new scanner called keyboard, that is accepting user
input.
name = keyboard.nextLine();
System.out.println(\"What is the person\'s age?\");
age = keyboard.nextInt();
while (age < 0)
{
System.out.println(\"Age cannot be negative.\");
System.out.println(\"Reenter age:\");
age = keyboard.nextInt();
}
}
public void writeOutput()
{
System.out.println(\"Name = \" + name);
System.out.println(\"Age = \" + age);
}
//method to set non negative age
public void set(String newName, int newAge)
{
name = newName;
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
}
//method to setting name
public void setName(String newName)
{
name = newName;
}
//method to set age
public void setAge(int newAge)
{
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
} //to get name
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
/*Boolean tests for if two persons are equal (same name and age), if two persons
have the same name, if two persons have the same age, if one person is older
than another, and if one person is younger than another.*/
public boolean equals(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name)
&& this.getAge() == another.getAge());
}
public boolean isSameName(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name));
}
public boolean isSameAge(PersonImproved another)
{
return(this.getAge() == another.getAge());
}
public boolean isOlderThan(PersonImproved another)
{
return(this.getAge() > another.getAge());
}
public boolean isYoungerThan(PersonImproved
another)
{
return(this.getAge() < another.getAge());
}
}
and this is the test file
public class PersonCh6Test
{
public static void main(String[] args)
{
System.out.println();
System.out.println(\"Test case 1: default constructor and\");
System.out.println(\"writeOutput() method.\");
System.out.println();
PersonCh6 secretAgent1 = new PersonCh6();
System.out.println(\"Results of default constructor:\");
System.out.println(\"Should be name = \\\"No name\\\" and\");
S.
Forecasting using data workshop slides for the Deliver conference in Winnipeg October 2016. This session introduces practical exercises for probabilistic forecasting. http://www.prdcdeliver.com
Im having an issue with the simulateOPT() methodthis is the p.pdfstopgolook
I'm having an issue with the simulateOPT() method
this is the purpose:
this is my code:
import java.util.Scanner;
public class Main {
private static int n;
private static int[] referenceString;
private static int[] physicalFrames;
private static int[] victimPages;
private static int pageFaults;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int choice;
do {
System.out.println("0 - Exit");
System.out.println("1 - Input N");
System.out.println("2 - Input the reference string");
System.out.println("3 - Simulate the OPT algorithm");
System.out.println("4 - Simulate the NEW algorithm");
System.out.print("Select option: ");
choice = input.nextInt();
switch (choice) {
case 0:
System.out.println("Exiting the program...");
break;
case 1:
System.out.print("Enter the value of N (2-8): ");
n = input.nextInt();
if (n < 2 || n > 8) {
System.out.println("Invalid value of N!");
n = 0;
} else {
physicalFrames = new int[n];
victimPages = new int[n];
System.out.println("N set to " + n + ".");
}
break;
case 2:
if (n == 0) {
System.out.println("Please enter the value of N first!");
} else {
System.out.print("Enter the reference string (length at least " + n + ", max length 20): ");
String[] strArr = input.next().split("");
int len = strArr.length;
if (len < n || len > 20) {
System.out.println("Invalid length of reference string!");
} else {
referenceString = new int[len];
for (int i = 0; i < len; i++) {
int page = Integer.parseInt(strArr[i]);
if (page < 0 || page > 9) {
System.out.println("Invalid page number!");
referenceString = null;
break;
}
referenceString[i] = page;
}
if (referenceString != null) {
System.out.println("Reference string set to " + String.join("", strArr) + ".");
}
}
}
break;
case 3:
if (n == 0) {
System.out.println("Please enter the value of N first!");
} else if (referenceString == null) {
System.out.println("Please enter the reference string first!");
} else {
System.out.println("Simulating the OPT algorithm...");
simulateOPT();
}
break;
case 4:
if (n == 0) {
System.out.println("Please enter the value of N first!");
} else if (referenceString == null) {
System.out.println("Please enter the reference string first!");
} else {
System.out.println("Simulating the NEW algorithm...");
simulateNEW();
}
break;
default:
System.out.println("Invalid choice!");
break;
}
System.out.println();
} while (choice != 0);
}
private static void simulateOPT() {
pageFaults = 0;
int len = referenceString.length;
System.out.println("Reference String\tPhysical Frames\tPage Faults\tVictim Pages");
for (int i = 0; i < len; i++) {
int page = referenceString[i];
boolean found = false;
for (int j = 0; j < n; j++) {
if (physicalFrames[j] == page) {
found = true;
break;
}
}
if (!found) {
pageFaults++;
int maxDist = 0;
int victimPage = -1;
for (int j = 0; j < n; j++) {
int dist = 0;
for (int k = i + 1; k < len; k++) {
dist++;
if (physicalFrames[j] == referenceString[k]) {
break;
}
}
if (dist > maxDist) {
maxDist = dist;
victimPage = j;
}
}
.
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
Create a menu-driven program that will accept a collection of non-negative integers from the
keyboard, calculate the mean and median values and display those values on the screen. Your
menu should have 6 options: 1. Add a number to the array 2. Display the mean 3. Display the
median 4. Print the array to the screen 5. Print the array in reverse order 6. Quit
Program particulars: Use an array of type int to store the integers entered by the user. There
must be error checking on the input integer. If it is negative, the program will print an error
message and re-prompt. This process will continue until a non-negative integer is entered. You
must use a try-catch structure to trap both types of input errors (like letters where numbers
should go) and range errors (like -1). You must write your own selectionSort utility method to
sort your array. Place the method in an external file named SortSearchUtil.java. There must be
error checking on the menu choice entered. If the user enters a choice not on the menu, the
program will print an error message, re-display the menu and re-prompt. This process will
continue until a valid option value is entered. Your solution must be modular. The design of your
methods is up to you, but the rules of “highly cohesive” and “loosely coupled” must be followed.
Your program should be well-documented. Explain what you’re doing in your code. Be sure to
include the usual name and assignment notes. Note your program will have to sort your array
before you can find the median. Include your SortSearchUtil.java file which will contain your
sort method.
This is what my project looks like already: Please fix it thanks. The SortSearchUtil will also be
included.
import java.util.Scanner;
public class ArraySorting
{
public static void main(String[] args)
{
int option;
int integer = 0;
int optionOne;
int optionTwo;
int optionThree;
int optionFour;
int optionFive;
int[] numbers = new int[5];
Scanner kb = new Scanner(System.in);
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
while((integer < 0))
{
System.out.println(\"I am sorry that is not a non-negative integer.\");
System.out.println(\"\");
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
}
option = displayMenu(kb);
while (option != 6)
{
switch (option)
{
case 1:
optionOne(numbers);
System.out.println(\"\");
break;
case 2:
optionTwo(numbers);
System.out.println(\"\");
case 3:
//optionThree();
System.out.println(\"\");
break;
case 4:
//optionFour();
System.out.println(\"\");
break;
case 5:
//optionFive();
System.out.println(\"\");
break;
}
option = displayMenu(kb);
}
if (option == 6)
{
System.out.println();
System.out.println(\"Thank you. Have a nice day.\");
}
}
private static int displayMenu(Scanner kb)
{
int option = 0;
while (option != 1 && option != 2 && option != 3 && option != 4 && option !=5 && option
!=6)
{
System.out.println(\"\\t\\t1. Add a number to the array\ \\t\\t2. Display the mean\ \\t\.
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdfarracollection
Repeat Programming Project 2 in Chapter 5. This time, add the following four constructor
methods: one for each instance variable, one with two parameters for the two instance variables,
and a default constructor. Be sure that each constructor sets all the instance variables. write a
driver program to test each of the methods, including each of the four constructors and at least
one true or false case for each of the test method.
this is the code that i have to add four constructor methods to
import java.util.*;
public class PersonImproved// Counter is the name of the class and i saved it in a file named
PersonImproved.
{
//Data members
private String name;
private int age;
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println(\"What is the person\'s name?\");// This gets the program ready for
keyboard input by telling us that there is a new scanner called keyboard, that is accepting user
input.
name = keyboard.nextLine();
System.out.println(\"What is the person\'s age?\");
age = keyboard.nextInt();
while (age < 0)
{
System.out.println(\"Age cannot be negative.\");
System.out.println(\"Reenter age:\");
age = keyboard.nextInt();
}
}
public void writeOutput()
{
System.out.println(\"Name = \" + name);
System.out.println(\"Age = \" + age);
}
//method to set non negative age
public void set(String newName, int newAge)
{
name = newName;
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
}
//method to setting name
public void setName(String newName)
{
name = newName;
}
//method to set age
public void setAge(int newAge)
{
if (newAge >= 0)
age = newAge;
else
{
System.out.println(\"ERROR: Used a negative age.\");
System.exit(0);
}
} //to get name
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
/*Boolean tests for if two persons are equal (same name and age), if two persons
have the same name, if two persons have the same age, if one person is older
than another, and if one person is younger than another.*/
public boolean equals(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name)
&& this.getAge() == another.getAge());
}
public boolean isSameName(PersonImproved another)
{
return(this.name.equalsIgnoreCase(another.name));
}
public boolean isSameAge(PersonImproved another)
{
return(this.getAge() == another.getAge());
}
public boolean isOlderThan(PersonImproved another)
{
return(this.getAge() > another.getAge());
}
public boolean isYoungerThan(PersonImproved
another)
{
return(this.getAge() < another.getAge());
}
}
and this is the test file
public class PersonCh6Test
{
public static void main(String[] args)
{
System.out.println();
System.out.println(\"Test case 1: default constructor and\");
System.out.println(\"writeOutput() method.\");
System.out.println();
PersonCh6 secretAgent1 = new PersonCh6();
System.out.println(\"Results of default constructor:\");
System.out.println(\"Should be name = \\\"No name\\\" and\");
S.
Forecasting using data workshop slides for the Deliver conference in Winnipeg October 2016. This session introduces practical exercises for probabilistic forecasting. http://www.prdcdeliver.com
Im having an issue with the simulateOPT() methodthis is the p.pdfstopgolook
I'm having an issue with the simulateOPT() method
this is the purpose:
this is my code:
import java.util.Scanner;
public class Main {
private static int n;
private static int[] referenceString;
private static int[] physicalFrames;
private static int[] victimPages;
private static int pageFaults;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int choice;
do {
System.out.println("0 - Exit");
System.out.println("1 - Input N");
System.out.println("2 - Input the reference string");
System.out.println("3 - Simulate the OPT algorithm");
System.out.println("4 - Simulate the NEW algorithm");
System.out.print("Select option: ");
choice = input.nextInt();
switch (choice) {
case 0:
System.out.println("Exiting the program...");
break;
case 1:
System.out.print("Enter the value of N (2-8): ");
n = input.nextInt();
if (n < 2 || n > 8) {
System.out.println("Invalid value of N!");
n = 0;
} else {
physicalFrames = new int[n];
victimPages = new int[n];
System.out.println("N set to " + n + ".");
}
break;
case 2:
if (n == 0) {
System.out.println("Please enter the value of N first!");
} else {
System.out.print("Enter the reference string (length at least " + n + ", max length 20): ");
String[] strArr = input.next().split("");
int len = strArr.length;
if (len < n || len > 20) {
System.out.println("Invalid length of reference string!");
} else {
referenceString = new int[len];
for (int i = 0; i < len; i++) {
int page = Integer.parseInt(strArr[i]);
if (page < 0 || page > 9) {
System.out.println("Invalid page number!");
referenceString = null;
break;
}
referenceString[i] = page;
}
if (referenceString != null) {
System.out.println("Reference string set to " + String.join("", strArr) + ".");
}
}
}
break;
case 3:
if (n == 0) {
System.out.println("Please enter the value of N first!");
} else if (referenceString == null) {
System.out.println("Please enter the reference string first!");
} else {
System.out.println("Simulating the OPT algorithm...");
simulateOPT();
}
break;
case 4:
if (n == 0) {
System.out.println("Please enter the value of N first!");
} else if (referenceString == null) {
System.out.println("Please enter the reference string first!");
} else {
System.out.println("Simulating the NEW algorithm...");
simulateNEW();
}
break;
default:
System.out.println("Invalid choice!");
break;
}
System.out.println();
} while (choice != 0);
}
private static void simulateOPT() {
pageFaults = 0;
int len = referenceString.length;
System.out.println("Reference String\tPhysical Frames\tPage Faults\tVictim Pages");
for (int i = 0; i < len; i++) {
int page = referenceString[i];
boolean found = false;
for (int j = 0; j < n; j++) {
if (physicalFrames[j] == page) {
found = true;
break;
}
}
if (!found) {
pageFaults++;
int maxDist = 0;
int victimPage = -1;
for (int j = 0; j < n; j++) {
int dist = 0;
for (int k = i + 1; k < len; k++) {
dist++;
if (physicalFrames[j] == referenceString[k]) {
break;
}
}
if (dist > maxDist) {
maxDist = dist;
victimPage = j;
}
}
.
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
Create a menu-driven program that will accept a collection of non-negative integers from the
keyboard, calculate the mean and median values and display those values on the screen. Your
menu should have 6 options: 1. Add a number to the array 2. Display the mean 3. Display the
median 4. Print the array to the screen 5. Print the array in reverse order 6. Quit
Program particulars: Use an array of type int to store the integers entered by the user. There
must be error checking on the input integer. If it is negative, the program will print an error
message and re-prompt. This process will continue until a non-negative integer is entered. You
must use a try-catch structure to trap both types of input errors (like letters where numbers
should go) and range errors (like -1). You must write your own selectionSort utility method to
sort your array. Place the method in an external file named SortSearchUtil.java. There must be
error checking on the menu choice entered. If the user enters a choice not on the menu, the
program will print an error message, re-display the menu and re-prompt. This process will
continue until a valid option value is entered. Your solution must be modular. The design of your
methods is up to you, but the rules of “highly cohesive” and “loosely coupled” must be followed.
Your program should be well-documented. Explain what you’re doing in your code. Be sure to
include the usual name and assignment notes. Note your program will have to sort your array
before you can find the median. Include your SortSearchUtil.java file which will contain your
sort method.
This is what my project looks like already: Please fix it thanks. The SortSearchUtil will also be
included.
import java.util.Scanner;
public class ArraySorting
{
public static void main(String[] args)
{
int option;
int integer = 0;
int optionOne;
int optionTwo;
int optionThree;
int optionFour;
int optionFive;
int[] numbers = new int[5];
Scanner kb = new Scanner(System.in);
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
while((integer < 0))
{
System.out.println(\"I am sorry that is not a non-negative integer.\");
System.out.println(\"\");
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
}
option = displayMenu(kb);
while (option != 6)
{
switch (option)
{
case 1:
optionOne(numbers);
System.out.println(\"\");
break;
case 2:
optionTwo(numbers);
System.out.println(\"\");
case 3:
//optionThree();
System.out.println(\"\");
break;
case 4:
//optionFour();
System.out.println(\"\");
break;
case 5:
//optionFive();
System.out.println(\"\");
break;
}
option = displayMenu(kb);
}
if (option == 6)
{
System.out.println();
System.out.println(\"Thank you. Have a nice day.\");
}
}
private static int displayMenu(Scanner kb)
{
int option = 0;
while (option != 1 && option != 2 && option != 3 && option != 4 && option !=5 && option
!=6)
{
System.out.println(\"\\t\\t1. Add a number to the array\ \\t\\t2. Display the mean\ \\t\.
The Guava project contains several of Google’s core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. There will be the slides presenting most useful and interesting features of Guava (v.12) that makes stuff simpler, better and code cleaner. We will cover most of the com.google.common.base.* classes and basic use of functions in collection and Google collections and few other features that are part of Guava and I find them very useful. Some of you will think that there is an overlap with Apache commons – and it’s true, but Guava is built with expectation that there is a Function and a Predicate class as well as various builders which makes it really cool and simple for many use cases.
TASK #1In the domain class you will create a loop that will prompt.pdfindiaartz
TASK #1
In the domain class you will create a loop that will prompt the user to enter a value of 1, 2, or 3,
which will in turn, be translated to a floor number in the game. Make sure the user only picks a
selection you are expecting (1, 2, or 3) with a while-loop. Then you will create a switch or if-else
statement. If you are more comfortable with if-else then do switch, or if you are more
comfortable with switch then do if-else. Based on the number the user chooses you will set the
floor variable to the appropriate value. When they select 1 floor should be set to 3, when they
select 2 floor should be set to 6, and when they select 3 floor should be set to 10.
TASK #2
In the domain class you will create a constructor with 6 parameters, representing all the data
loaded from the input file that was saved from a previous adventure. This constructor receives 6
parameters: aName, anAttack, aDefense, aHealth, aCurrentFloor, & aMaxFloor.
TASK #3
In the domain class you will create a save method that will allow the user to save their progress
using a PrintWriter object. This file will overwrite whatever was there before, so no need to use
FileWriter, only PrintWriter. There are 6 attributes that you need to write to the file:
name, attack, defense, health, currentFloor, & maxFloor
public void saveFile()
{
String filename = “game.txt”;
PrintWriter pw = new PrintWriter(filename);
pw.println(name);
pw.println(attack);
pw.println(defense);
pw.println(health);
pw.println(currentFloor);
pw.println(maxFloor);
pw.close();
}
TASK #4
In the driver class you will create a load method that will allow the user to pick up from where
they left off. You will do this using a File object and a Scanner object. Remember to use the File
and Scanner classes, and to close the file object after you’re done. There are 6 attributes you will
need to load from the file to successfully continue an Adventure:
name, attack, defense, health, currentFloor, & maxFloor
After you read the record from the file, and store the data in these 6 variables, you can create a
new Adventure object called JavaQuest with those 6 variables. Remember JavaQuest is a global
variable defined at the beginning of the driver class. Then, within the load method, invoke the
startAdventure() method for the newly created Adventure object.
public static void load()
{
String filename = “load.txt”;
File myFile = new File(filename);
Scanner myScan = new Scanner(myFile);
String name;
int attack, defense, health, currentFloor, maxFloor;
name = myScan.nextLine();
attack = myScan.nextInt();
myScan.nextLine();
defense = myScan.nextInt();
myScan.nextLine();
…
javaQuest = new Adventure(name, attack, defense, health, currentFloor, maxFloor);
}
javaQuest.startAdventure();
The Files
package Adventure;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Scanner;
public class Adventure
{
int health, defense, attack;
String mons.
Lazy Java by Mario Fusco
Like all imperative languages Java is, with some minor but notable exceptions, an eagerly evaluated programming language. Nevertheless the introduction of lambdas in Java 8 also allowed the adoption of some lazy patterns and data structures that are more typically employed in functional languages. Streams represent the most evident example of how also native Java API has taken advantage of laziness, but there is a number of other interesting scenarios where laziness can be an effective solution to quite common problems. In fact laziness is the only possible technique to process potentially infinite amount of data, or more in general to delay the expensive evaluation of an expression only when and if it is necessary. But laziness is even more than that: for instance the reader monad delays not only a computation but also the need of external dependencies thus lowering the abuse of dependency injection, while a trampoline uses laziness to delay and then linearize recursive calls preventing the overflow of the stack. The purpose of this talk is illustrating why and how implementing laziness in Java with practical examples delivered with both slides and live coding sessions.
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