diff --git a/first/pom.xml b/Basics/pom.xml similarity index 100% rename from first/pom.xml rename to Basics/pom.xml diff --git a/Basics/src/main/java/com/example/Basics.java b/Basics/src/main/java/com/example/Basics.java new file mode 100644 index 0000000..11a7647 --- /dev/null +++ b/Basics/src/main/java/com/example/Basics.java @@ -0,0 +1,106 @@ +package com.example; +import java.util.Scanner; //We need to importthis class to get text from the command line + +public class Basics { + public static void main(String[] args) { + System.out.println("Write once, run anywhere"); + System.out.println("Write once, run anywhere!"); + + int a = 5; + int b = 3; + int z = a%b; + System.out.println(a-z); + + Scanner sc = new Scanner(System.in); //After importing the Scanner class, we need to create a Scanner object + System.out.print("Gimme your name: "); + String name = sc.nextLine(); + + System.out.print("Gimme your age: "); + int age = sc.nextInt(); + + System.out.println("Your name is: " + name); + System.out.println("Your age is: " + age); + + + /* + Task: Take the bill amount as input and output the corresponding tip amount, which should be 15% of the amount. + */ + //System.out.print("Gimme the amount: "); + System.out.print("Payment: "); + if (!(age < 18)) { + double amount = sc.nextDouble(); + System.out.println(amount*15/100); + }else{ + System.out.println("You are not old enaugh to tip!"); + } + + /* + You are making a program for a water sensor that should check if the water is boiling. + Take the integer temperature in Celsius as input and output "Boiling" if the temperature is above or equal to 100. + Output "Not boiling" if it's not. + */ + System.out.print("What is the waters temperature? "); + int temp = sc.nextInt(); + if (temp >= 100) { + System.out.println("Boiling"); + }else{ + System.out.println("Not boiling"); + } + + if (age < 18) { + System.out.print("Give me the number of the day: "); + int day = sc.nextInt(); + switch (day) { + case 1: + System.out.println("Monday"); + break; + case 2: + System.out.println("Tuesday"); + break; + case 3: + System.out.println("Wednesday"); + break; + + default: + System.out.println("Some Other day, or whatever."); + break; + } + } + + /* + You are making a robot that should categorize items by their color. + Each color corresponds to a box with a specific number. + For simplicity, our program will handle 3 colors: + red goes to box #1 + green goes to box #2 + black goes to box #3 + + Your program needs to take a color as input and output the corresponding box number. + Sample Input + green + Sample Output + 2 + */ + + System.out.print("Gimme a color: "); + Scanner sci = new Scanner(System.in); + String color = sci.nextLine(); + switch (color) { + case "red": + System.out.println(1); + break; + case "green": + System.out.println(2); + break; + case "black": + System.out.println(3); + break; + + default: + System.out.println("Something else!"); + break; + } + sc.close(); + sci.close(); + } +} \ No newline at end of file diff --git a/Basics/target/classes/com/example/Main.class b/Basics/target/classes/com/example/Main.class new file mode 100644 index 0000000..77e9261 Binary files /dev/null and b/Basics/target/classes/com/example/Main.class differ diff --git a/first/src/main/java/com/example/Main.java b/first/src/main/java/com/example/Main.java deleted file mode 100644 index 2422524..0000000 --- a/first/src/main/java/com/example/Main.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example; - -public class Main { - public static void main(String[] args) { - System.out.println("Write once, run anywhere"); - System.out.println("Write once, run anywhere!"); - - int a = 5; - int b = 3; - int z = a%b; - System.out.println(a-z); - - } -} \ No newline at end of file diff --git a/first/target/classes/com/example/Main.class b/first/target/classes/com/example/Main.class deleted file mode 100644 index 39cc50f..0000000 Binary files a/first/target/classes/com/example/Main.class and /dev/null differ