lab10 go brrr, pt2
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
|
||||
*/
|
||||
package inclassoct6th;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class InClassOct6th {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create a scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
//Define args
|
||||
int number1 = 5, number2 = 17;
|
||||
|
||||
System.out.print("What is " + number1 + " + " + number2 + "? ");
|
||||
int answer = input.nextInt();
|
||||
|
||||
while (number1 + number2 != answer)
|
||||
{
|
||||
System.out.println("Wrong answer, try again. What is " + number1 + " + " + number2 + "?");
|
||||
answer = input.nextInt();
|
||||
}
|
||||
System.out.println("You got it!");
|
||||
}
|
||||
|
||||
}
|
25
Assignments/InClassOct6th/src/inclassoct6th/Menu.java
Normal file
25
Assignments/InClassOct6th/src/inclassoct6th/Menu.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package inclassoct6th;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Menu {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner input = new Scanner(System.in);
|
||||
int usersChoice;
|
||||
do {
|
||||
System.out.println("type 1, 2, or 3: ");
|
||||
System.out.println("type 0 to quit.");
|
||||
usersChoice = input.nextInt();
|
||||
} while (usersChoice != 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user