Reset author name to chosen name ✨
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class And1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.print("please enter a number between 0 and 10: ");
|
||||
int number = new Scanner(System.in).nextInt();
|
||||
|
||||
/*
|
||||
the &&is the AND operator which ANDs 2 operands
|
||||
The ANDing evaluates to true if both of the operands of the AND are true
|
||||
UNDERSTAND THIS AND &&, please
|
||||
*/
|
||||
if ( number >= 0 && number <= 10 )
|
||||
System.out.println("\nthank you for entering number " + number );
|
||||
else
|
||||
System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?");
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class And2 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create Scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Setup vars
|
||||
int number;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Please enter a number that is divisable by 10 and greater than 100: ");
|
||||
number = input.nextInt();
|
||||
|
||||
// Compute
|
||||
if ( number % 10 == 0 && number > 100)
|
||||
{
|
||||
System.out.println("Thanks for entering number " + number+ "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(number + " is not fufilling the request!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Bonus {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
//Setup currency formatter
|
||||
NumberFormat defaultFormat = NumberFormat.getCurrencyInstance();
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Setup vars
|
||||
String lastName,
|
||||
firstName;
|
||||
double thisYearsUnits,
|
||||
lastYearsUnits,
|
||||
bonus = 0;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Enter last name: ");
|
||||
lastName = input.nextLine();
|
||||
System.out.print("Enter first name: ");
|
||||
firstName = input.nextLine();
|
||||
System.out.print("Enter this year's units: ");
|
||||
thisYearsUnits = input.nextDouble();
|
||||
System.out.print("Enter last year's units: ");
|
||||
lastYearsUnits = input.nextDouble();
|
||||
|
||||
// Compute!
|
||||
if (thisYearsUnits > lastYearsUnits) {
|
||||
if (1000 > thisYearsUnits) // If thisYearsUnits is less than 1000
|
||||
bonus = 25;
|
||||
else if (thisYearsUnits > 1000 && thisYearsUnits < 3000) // If thisYearsUnits is more than 1000, but less than 3000
|
||||
bonus = 50;
|
||||
else if (thisYearsUnits > 3000 && thisYearsUnits < 6000) // If thisYearsUnits is more than 3000, but less than 6000
|
||||
bonus = 100;
|
||||
else if (thisYearsUnits > 6000) // 6000 and up
|
||||
bonus = 200;
|
||||
}
|
||||
|
||||
// Output
|
||||
System.out.println("Employee Name: ");
|
||||
System.out.println("\t"+ lastName + ", " + firstName);
|
||||
System.out.println("Bonus is "+ defaultFormat.format(bonus));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Debug1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int i=1, j=2, k=3;
|
||||
if (i < j && i < k && j < k)
|
||||
{
|
||||
System.out.println("i, j, and k are in increasing order");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class DivisionQuiz {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
// Setup variables
|
||||
int number1,
|
||||
number2,
|
||||
answerQuotient,
|
||||
answerRemainder;
|
||||
boolean cheatMode = false; // Used for debugging
|
||||
|
||||
while (true) {
|
||||
// Get random numbers between 1-100
|
||||
number1 = (int) (Math.random() * 100);
|
||||
number2 = (int) (Math.random() * 100);
|
||||
|
||||
// If number1 < number2, flip them
|
||||
if (number1 < number2) {
|
||||
int tmp = number2;
|
||||
number2 = number1;
|
||||
number1 = tmp;
|
||||
}
|
||||
|
||||
//Prompt
|
||||
if (cheatMode == true) {
|
||||
System.out.println("CHEAT MODE: the quotient of " + number1 + " / " + number2 + " is " + (number1 / number2));
|
||||
}
|
||||
System.out.print(" What is the quotient of " + number1 + " / " + number2 + "? ");
|
||||
answerQuotient = input.nextInt();
|
||||
if (cheatMode == true) {
|
||||
System.out.println("CHEAT MODE: the remainder of " + number1 + " % " + number2 + " is " + (number1 % number2));
|
||||
}
|
||||
System.out.print(" What is the remainder of " + number1 + " / " + number2 + "? ");
|
||||
answerRemainder = input.nextInt();
|
||||
|
||||
// Check if answers are correct
|
||||
if ((number1 / number2) == answerQuotient) //Checks the quotient
|
||||
{
|
||||
System.out.println("You are correct about the quotient!");
|
||||
} else {
|
||||
System.out.println("You are wrong about the quotient.");
|
||||
System.out.println("The quotient of " + number1 + " / " + number2 + " is " + (number1 / number2));
|
||||
}
|
||||
if ((number1 % number2) == answerRemainder) //Checks the remainder
|
||||
{
|
||||
System.out.println("You are correct about the remainder!");
|
||||
} else {
|
||||
System.out.println("You are wrong about the remainder.");
|
||||
System.out.println("The remainder of " + number1 + " % " + number2 + " is " + (number1 % number2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Not1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.print("Please enter a number between 0 and 10: ");
|
||||
int number = new Scanner(System.in).nextInt();
|
||||
/*
|
||||
The ! is the NOT operator which reverses a boolean expression.
|
||||
If the expression is true, the not makes it false and vice-versa.
|
||||
|
||||
the || is the OR operator which ORs 2 operands
|
||||
This is the equivalent AND1 by using OR and NOT
|
||||
|
||||
1. The && is replaced by ||
|
||||
2. The relational operators are reversed
|
||||
3. There is a ! (NOT) outside the prenthesis
|
||||
*/
|
||||
if ( ! (number < 0 || number > 10) )
|
||||
{
|
||||
System.out.println("\nThank you for entering number " + number + "!");
|
||||
}
|
||||
else {
|
||||
System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Not2 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create Scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Setup vars
|
||||
int number;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Please enter a number that is divisable by 10 and greater than 100: ");
|
||||
number = input.nextInt();
|
||||
|
||||
// Compute
|
||||
//if ( number % 10 == 0 && number > 100)
|
||||
if ( ! (number % 10 != 0 || number < 100) )
|
||||
{
|
||||
System.out.println("Thanks for entering number " + number+ "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(number + " is not fufilling the request!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Or1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("Please enter a number less than 0 or greater than or equal to 1,000");
|
||||
int number = new Scanner(System.in).nextInt();
|
||||
|
||||
/*
|
||||
The || is the OR operator which ORs 2 operands
|
||||
The ORing evaluates to true if either of the operands of the OR is true
|
||||
UNDERSTAND THIS OR || please
|
||||
*/
|
||||
if (number < 0 || number >= 1000)
|
||||
System.out.println("\nThank you for entering number " + number );
|
||||
else
|
||||
System.out.println("\n " + number + " is not fulfilling the request!");
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Or2 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Define vars
|
||||
int number;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Please enter a number less than 0 or divisable by 3 or both: ");
|
||||
number = input.nextInt();
|
||||
|
||||
// Compute
|
||||
if ( number % 3 == 0 || number < 0)
|
||||
{
|
||||
System.out.println("Thank you for entering number " + number);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(number + " is not fufilling the request!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* 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 com.chloefontenot.lab7_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class SubtractionQuiz {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner outside of loop so we don't create it over and over again
|
||||
Scanner input = new Scanner(System.in);
|
||||
while(true) {
|
||||
// 1. Generate two random single-digit integers
|
||||
int number1 = (int)(Math.random() * 10);
|
||||
int number2 = (int)(Math.random() * 10);
|
||||
|
||||
// 2. If number < number2, swap number1 with number2
|
||||
if (number1 < number2)
|
||||
{
|
||||
int temp = number1;
|
||||
number1 = number2;
|
||||
number2 = temp;
|
||||
}
|
||||
|
||||
// 3. Prompt the student to answer "what is number1 - number2?"
|
||||
System.out.print("What is " + number1 + " - " + number2 + "? ");
|
||||
int answer = input.nextInt();
|
||||
|
||||
// 4. Grade the answer and display the result
|
||||
if (number1 - number2 == answer)
|
||||
System.out.println("You are correct!");
|
||||
else
|
||||
{
|
||||
System.out.println("Your answer is wrong.");
|
||||
System.out.println(number1 + " - " + number2 + "should be" + (number1 - number2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user