mirror of
https://github.com/sys-32Dev/CS2011.git
synced 2026-08-08 20:06:05 +00:00
adding new assignments
This commit is contained in:
BIN
Code/HelloWorld.class
Normal file
BIN
Code/HelloWorld.class
Normal file
Binary file not shown.
13
Code/HelloWorld.java
Normal file
13
Code/HelloWorld.java
Normal 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
BIN
Code/PizzasAndPeople.class
Normal file
Binary file not shown.
26
Code/PizzasAndPeople.java
Normal file
26
Code/PizzasAndPeople.java
Normal 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
33
Code/test.java
Normal 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
18
CurrencyConversion.java
Normal 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
BIN
NumericalTypesDemo.class
Normal file
Binary file not shown.
13
NumericalTypesDemo.java
Normal file
13
NumericalTypesDemo.java
Normal 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
34
PizzasForThePeople.java
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user