2022-09-07 Booleans and Ifs
import java.util.*;
class Main{
public static void main(String args[]){
boolean position = true;
boolean velocity = true;
boolean acceleration = true;
Scanner input = new Scanner(System.in);
for(int i = 0; i < 2; i++){
System.out.print("velocity or no: ");
String words = input.nextLine();
System.out.println(words);
if(words.equals("yes")){
velocity = false;
position = true ;
}else {
acceleration = true;
position = true;
velocity = true;
}
if (position && velocity && acceleration) {
System.out.println("it gets there");
}
else if (!position || !velocity) {
System.out.println("it doesn't really get there");
}
else if (velocity && !acceleration) {
System.out.println("it stand still");
}
else if(!position){
System.out.println("is breaking");
}
}
}
}
Main.main(null);
import java.util.*;
class Main{
public static void main(String args[]){
boolean position = true;
boolean velocity = true;
boolean acceleration = true;
for(int i = 0; i < 2; i++){
Scanner input = new Scanner(System.in);
System.out.print("velocity or no: ");
String words = input.nextLine();
System.out.println(words);
switch(words){
case ("yes"):
velocity = false;
position = true ;
break;
case ("no"):
acceleration = true;
position = true;
velocity = true;
break;
default:
System.out.print("Try a different input");
break;
}
if (position && velocity && acceleration) {
System.out.println("it gets there");
}
else if (!position || !velocity) {
System.out.println("it doesn't really get there");
}
else if (velocity && !acceleration) {
System.out.println("it stand still");
}
else if(!position){
System.out.println("is breaking");
}
}
}
}
Main.main(null);
int x = 1;
int y = 2;
if(!(x < 2 && y > 1)){
System.out.println("Hello");
}
else if(!(x < 2 || y > 1)){
System.out.println("Good Day");
}