diff --git a/Basic/BooleansComparision.class b/Basic/BooleansComparision.class new file mode 100644 index 0000000..aa955fb Binary files /dev/null and b/Basic/BooleansComparision.class differ diff --git a/Basic/BooleansComparision.java b/Basic/BooleansComparision.java new file mode 100644 index 0000000..7c3092e --- /dev/null +++ b/Basic/BooleansComparision.java @@ -0,0 +1,12 @@ +public class BooleansComparision{ + public static void main(String[] arg){ + String chemistryGrade = "25"; + String biologyGrade = "75"; + String englishGrade = "25"; + System.out.println(!chemistryGrade.equals(englishGrade)); + System.out.println(!biologyGrade.equals(englishGrade)); + System.out.println(chemistryGrade.equals(englishGrade)); + + + } +} \ No newline at end of file diff --git a/Basic/Dealership.class b/Basic/Dealership.class new file mode 100644 index 0000000..c03f050 Binary files /dev/null and b/Basic/Dealership.class differ diff --git a/Basic/Dealership.java b/Basic/Dealership.java new file mode 100644 index 0000000..b999d4d --- /dev/null +++ b/Basic/Dealership.java @@ -0,0 +1,51 @@ +import java.util.Scanner; + +public class Dealership { + public static void main(String []arg){ + Scanner scan = new Scanner (System.in); + //a simple application that uses switch statements and if-else statments for car dealership + //show options available + System.out.println("Welcome to the Java Dealership"); + System.out.println("-Select option 'a' to buy a car"); + System.out.println("-Select option 'b' to sell a car"); + //take user input + String option = scan.nextLine(); + + switch (option){ + //to buy a car + case "a" :System.out.println("What is your budget?"); + int budget = scan.nextInt(); + if(budget >= 30000){ + System.out.println("Great! A Dodge charger is available"); + System.out.println("\nDo you have an insurance? Write 'Yes' or 'No'"); + scan.nextLine(); + String insurance = scan.nextLine(); + System.out.println("\nDo you have a driver's licence? 'Yes' or 'no'"); + String licence = scan.nextLine(); + System.out.println("\nWhat is your credit score?"); + int creditScore = scan.nextInt(); + if(insurance.equals("yes") && licence.equals("yes") && creditScore > 660){ + System.out.println("\nSold! Pleasure doing business with you"); + } else { + System.out.println("We're sorry. You are not eligible."); + } + + }break; + + //to sell a car + case "b" :System.out.println("\nWhat is your car valued at?"); + int value = scan.nextInt(); + System.out.println("\nWhat is you selling price?"); + int price = scan.nextInt(); + + if (value > price && price < 30000){ + System.out.println("\nWe will buy your car. Pleasure doing business with you!"); + } else { + System.out.println("\nSorry, we are not interested.");; + }break; + + default :System.out.println("Invalid option"); + } + scan.close(); + } +} \ No newline at end of file diff --git a/Basic/IfElse.class b/Basic/IfElse.class new file mode 100644 index 0000000..85a7c55 Binary files /dev/null and b/Basic/IfElse.class differ diff --git a/Basic/IfElse.java b/Basic/IfElse.java new file mode 100644 index 0000000..b8feeb0 --- /dev/null +++ b/Basic/IfElse.java @@ -0,0 +1,20 @@ +public class IfElse { + public static void main(String []arg){ + int grade = 88; + double gpa = 5.0; + if(grade>=80 && gpa >=4.0){ + System.out.println("You got an A"); + }else if(grade >= 70 && gpa >= 3.0){ + System.out.println("You got a B"); + }else if(grade >= 60 && gpa >= 2.0){ + System.out.println("You got a c"); + }else if(grade <60 && gpa <2){ + System.out.println("You got a D"); + }else{ + System.out.println("Study hard next time."); + } + + } + + +} diff --git a/Basic/LogicalOperators.class b/Basic/LogicalOperators.class new file mode 100644 index 0000000..83616f0 Binary files /dev/null and b/Basic/LogicalOperators.class differ diff --git a/Basic/LogicalOperators.java b/Basic/LogicalOperators.java new file mode 100644 index 0000000..aa04bd1 --- /dev/null +++ b/Basic/LogicalOperators.java @@ -0,0 +1,15 @@ +public class LogicalOperators { + public static void main(String []arg){ + int chemistry = 58; + int eng = 67; + String lang = "Java"; + if(chemistry > 75 || eng > 75 || lang.equals("Java")){ + System.out.println("you got admission"); + + }else{ + System.out.println("we are sorry"); + } + + } + +} diff --git a/Basic/SwitchStatement.class b/Basic/SwitchStatement.class new file mode 100644 index 0000000..16eab83 Binary files /dev/null and b/Basic/SwitchStatement.class differ diff --git a/Basic/SwitchStatement.java b/Basic/SwitchStatement.java new file mode 100644 index 0000000..d535230 --- /dev/null +++ b/Basic/SwitchStatement.java @@ -0,0 +1,22 @@ +public class SwitchStatement { + public static void main(String []arg){ + int month = 5; + switch (month){ + //checks the value declared with the case value + case 1 : System.out.println("January"); break; + case 2 : System.out.println("February"); break; + case 3 : System.out.println("March"); break; + case 4 : System.out.println("April"); break; + case 5 : System.out.println("May"); break; + case 6 : System.out.println("june"); break; + case 7 : System.out.println("July"); break; + case 8 : System.out.println("August"); break; + case 9 : System.out.println("September"); break; + case 10 : System.out.println("October"); break; + case 11 : System.out.println("November"); break; + case 12 : System.out.println("December"); break; + default : System.out.println("Please enter a valid month"); + } + } + +}