From 74b2480c6f0aa88cff197757cabeadab6c23859d Mon Sep 17 00:00:00 2001 From: Kilokem Date: Thu, 12 Sep 2024 18:46:39 +0200 Subject: [PATCH] FirstFewLessons --- {first => Basics}/pom.xml | 0 Basics/src/main/java/com/example/Basics.java | 106 +++++++++++++++++++ Basics/target/classes/com/example/Main.class | Bin 0 -> 533 bytes first/src/main/java/com/example/Main.java | 14 --- first/target/classes/com/example/Main.class | Bin 691 -> 0 bytes 5 files changed, 106 insertions(+), 14 deletions(-) rename {first => Basics}/pom.xml (100%) create mode 100644 Basics/src/main/java/com/example/Basics.java create mode 100644 Basics/target/classes/com/example/Main.class delete mode 100644 first/src/main/java/com/example/Main.java delete mode 100644 first/target/classes/com/example/Main.class 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 0000000000000000000000000000000000000000..77e92616e6bebb4ede567cf8d1cb51c218148ab4 GIT binary patch literal 533 zcmah`!A`TS892f26>^`Oxc>H)+UPusG4+zVs0u~1~VyA6ztv^SLlP70y&M67hcL!%u}`bXR@ z^v05hiQ_4k$IqeUsW|tODCUmj136Ry)ly2u5!a6aA1Y7UHY}`_ki$Adt=U;fcVnZ1 zQ9HF(?ojD<;ycpx1gSApJK7aqUl^6f^JF$2t0;Z@yMZ=M=aU(Rdh=nKgoQdohYCXe$MUMOPCu3WNNJjMJ7b`6F0R zsf&IkAD|3qX)ypmDh#+pF$B-NQ}Cvl+Ow9{GKmht7+GnI0Xb+jyO2-N1x55W~|VoSi9 zntCBSYaK1#DPPmNPBl8Lf$#=*%=KC(-43k+JsQ23J zwro!I*7S-FI5{s0X?MsHKwd!_x>=JbGmYwPqD?fc5xb7T=VIjWQ{E7swlNv;kV3}bIm70>a4 cp3A(Kcty@SxnI-DG24MhE6-?`IXU$H0?!tSdH?_b