diff --git a/Basics/target/classes/com/example/Basics.class b/Basics/target/classes/com/example/Basics.class new file mode 100644 index 0000000..9fc26b5 Binary files /dev/null and b/Basics/target/classes/com/example/Basics.class differ diff --git a/Basics/target/classes/com/example/Main.class b/Basics/target/classes/com/example/Main.class deleted file mode 100644 index 77e9261..0000000 Binary files a/Basics/target/classes/com/example/Main.class and /dev/null differ diff --git a/Basics_II/src/main/java/com/example/BasicII.java b/Basics_II/src/main/java/com/example/BasicII.java new file mode 100644 index 0000000..8ffe9bf --- /dev/null +++ b/Basics_II/src/main/java/com/example/BasicII.java @@ -0,0 +1,46 @@ +package com.example; +import java.util.Scanner; + +public class BasicII { + public static void main(String[] args) { + System.out.println("Hello world!"); + + int [] ages; + ages = new int[10]; + int [] numbers = {15, 36, 18, 24, 47, 59, 26}; + ages[2] = 15; + ages[0] = 18; + System.out.println(numbers[3]); + + /* + You are making a program for a vending machine that provides drinks. + The menu of the drinks is stored in an array called menu: + String[] menu = {"Tea", "Espresso", "Americano", "Water", "Hot Chocolate"}; + JAVA + Take the choice of the customer as an integer from input and output the corresponding menu item. + Also, check for errors: in case the input is out of the range of the array, output "Invalid". + */ + String[] menu = {"Tea", "Espresso", "Americano", "Water", "Hot Chocolate"}; + Scanner sc = new Scanner(System.in); + System.out.print("Your chouse from the vending machine [0-4]: "); + int choice = sc.nextInt(); + if (choice > 4 || choice < 0) { + System.out.println("Invalid"); + }else{ + System.out.println(menu[choice]); + } + + /* + The given code declares an array that holds the monthly revenues for a company for a year. + You need to calculate the average monthly revenue for the year. + For that, calculate the sum of the revenue for all the months and divide it by the number of items in the array. + */ + double[] revenue = {88750, 125430, 99700, 14500, 158000, 65000, 99000, 189000, 210000, 42000, 165800, 258900}; + double sum = 0; + for (double d : revenue) { + sum += d; + } + System.out.println(sum/revenue.length); + + } +} \ No newline at end of file diff --git a/Basics_II/src/main/java/com/example/Main.java b/Basics_II/src/main/java/com/example/Main.java deleted file mode 100644 index b47156f..0000000 --- a/Basics_II/src/main/java/com/example/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.example; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/Basics_II/target/classes/com/example/BasicII.class b/Basics_II/target/classes/com/example/BasicII.class new file mode 100644 index 0000000..e058eb3 Binary files /dev/null and b/Basics_II/target/classes/com/example/BasicII.class differ diff --git a/Basics_II/target/classes/com/example/Main.class b/Basics_II/target/classes/com/example/Main.class deleted file mode 100644 index 54adadc..0000000 Binary files a/Basics_II/target/classes/com/example/Main.class and /dev/null differ