adding new assignments

This commit is contained in:
sys_32
2024-02-21 19:12:16 -08:00
parent fca4df9cd9
commit a1aee41e05
9 changed files with 137 additions and 0 deletions

BIN
Code/HelloWorld.class Normal file

Binary file not shown.

13
Code/HelloWorld.java Normal file
View File

@@ -0,0 +1,13 @@
/* Name 1: Edwin Hui
* Name 2:
* Your Course Number (CS2011)
* Your Section Numbers: 09 & 10
* Description: Fixing Bugs in .java files.
*/
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World!");
System.out.println("I really dont wan't to be awake right now.");
}
}

BIN
Code/PizzasAndPeople.class Normal file

Binary file not shown.

26
Code/PizzasAndPeople.java Normal file
View File

@@ -0,0 +1,26 @@
/* Name 1 Edwin Hui
* Name 2 Laura Martinez
* Your Course Number CS2011
* Your Section Numbers: 9 & 10
* Description: This lab introduces the use of the Scanner class to read input from the keyboard.
* Other Comments: NA
*/
import java.util.Scanner;
public class PizzasAndPeople {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.print("How many pizzas?");
int totalPizzas = scan.nextInt();
System.out.print("How many slices per pizza?");
int slicesPerPizza = scan.nextInt();
System.out.print("How many people?");
int totalPeople = scan.nextInt();
int numSlicesLeft = (totalPizzas * slicesPerPizza) % totalPeople;
System.out.println("There are " + numSlicesLeft + " slices left.");
scan.close();
}
}

33
Code/test.java Normal file
View File

@@ -0,0 +1,33 @@
import java.util.Scanner;
public class test {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.print("How many pizzas?");
int totalPizzas = scan.nextInt();
if(totalPizzas < 0){
System.out.println("Cannot have negative pizzas.");
System.exit(0);
}
System.out.print("How many slices per pizza?");
int slicesPerPizza = scan.nextInt();
if (slicesPerPizza < 0){
System.out.println("Cannot have negative slices.");
System.exit(0);
}
System.out.print("How many people?");
int totalPeople = scan.nextInt();
if (totalPeople < 0){
System.out.println("Cannot have negative people.");
System.exit(0);
}
int numSlicesLeft = (totalPizzas * slicesPerPizza) % totalPeople;
int numPizzaLeft = numSlicesLeft / slicesPerPizza;
int numSlices = (numPizzaLeft * totalPeople) - numSlicesLeft;
System.out.println("There are "+ numPizzaLeft + " whole pizzas and " + numSlices + " slices left.");
scan.close();
}
}

18
CurrencyConversion.java Normal file
View File

@@ -0,0 +1,18 @@
/* Name 1 Edwin Hui
* Name 2 Laura Martinez
* Your Course Number CS2011
* Your Section Numbers: 9 & 10
* Description: This lab introduces the use of the Scanner class to read input from the keyboard.
* Other Comments: NA
*/
import java.util.Scanner;
public class CurrencyConversion {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.print("How much yen are you exchanging? ");
double yen = scan.nextDouble();
double usd = yen / 146.36;
System.out.println(yen + " yen is " + usd + " U.S. dollars.");
scan.close();
}
}

BIN
NumericalTypesDemo.class Normal file

Binary file not shown.

13
NumericalTypesDemo.java Normal file
View File

@@ -0,0 +1,13 @@
public class NumericalTypesDemo{
public static void main(String[] args){
byte smol = 80;
int big = smol;
big = 200;
smol = (byte) big;
System.out.println("big is:" + big);
double decimalnum = 80.0;
smol = (byte) decimalnum;
System.out.println("smol is:" + smol);
}
}

34
PizzasForThePeople.java Normal file
View File

@@ -0,0 +1,34 @@
/* Name 1 Edwin Hui
* Name 2 Laura Martinez
* Your Course Number CS2011
* Your Section Numbers: 9 & 10
* Description: This lab introduces the use of the Scanner class to read input from the keyboard.
* Other Comments: NA
*/
import java.util.Scanner;
public class PizzasForThePeople {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.print("How many pizzas?");
int totalPizzas = scan.nextInt();
System.out.print("How many slices per pizza?");
int slicesPerPizza = scan.nextInt();
System.out.print("How many people?");
int totalPeople = scan.nextInt();
int numSlicesUncalc = (totalPizzas * slicesPerPizza) % totalPeople;
int numPizzaLeft = numSlicesUncalc / slicesPerPizza;
int numSlices = numSlicesUncalc % slicesPerPizza;
if (numPizzaLeft == 0){
numSlices = numSlicesUncalc;
}
System.out.println("There are "+ numPizzaLeft + " whole pizzas and " + numSlices + " slices left.");
scan.close();
}
}