Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Basic/BooleansComparision.class
Binary file not shown.
12 changes: 12 additions & 0 deletions Basic/BooleansComparision.java
Original file line number Diff line number Diff line change
@@ -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));


}
}
Binary file added Basic/Dealership.class
Binary file not shown.
51 changes: 51 additions & 0 deletions Basic/Dealership.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
Binary file added Basic/IfElse.class
Binary file not shown.
20 changes: 20 additions & 0 deletions Basic/IfElse.java
Original file line number Diff line number Diff line change
@@ -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.");
}

}


}
Binary file added Basic/LogicalOperators.class
Binary file not shown.
15 changes: 15 additions & 0 deletions Basic/LogicalOperators.java
Original file line number Diff line number Diff line change
@@ -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");
}

}

}
Binary file added Basic/SwitchStatement.class
Binary file not shown.
22 changes: 22 additions & 0 deletions Basic/SwitchStatement.java
Original file line number Diff line number Diff line change
@@ -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");
}
}

}