I got this as the "if" statement version. I have changed a few things but please let me know if the concept is correct! public static void main(String[] args) { System.out.println("What is your name?"); String name1 = "Caleb"; String name2 = "Monica"; Scanner scanner = new Scanner (System.in); String name = scanner.nextLine(); if(name.equals(name1)) { System.out.println("You are male"); } else if(name.equals(name2)) { System.out.println("You are female "); } } }
if (name.equals("caleb") || name.equals("clare")){ System.out.println("Go away'); } else{ System.out.println("Try again later"); } That's my solution, i hope it has no errors!
Clare is like a recurring theme throughout these videos and I've never wanted to know more about someone's life until I watched these videos. Who tf is Clare?? We need to know!
Props to you Caleb. Before I watched this video I had never even heard of the switch statement, let alone used it in coding. Thanks to you I now feel like I know exactly how to use it with confidence. You explained it brilliantly in 8 minutes. Thank you! :)
if (name.equals("Caleb")) { System.out.println("Welcome my man"); } else if (name.equals("Clare")) { System.out.println("Go away"); } else { System.out.println("Try again later"); } Thank you so much for these tutorials!
Woowww, I'm glad that I'm finally learning something. I also made a switch statement for fun. Here y'all go: System.out.println("Who are you?"); Scanner scnr = new Scanner(System.in); String student = scnr.nextLine(); switch(student){ case "Melissa": System.out.println("Welcome" + '\t' + student + "!"); break; case "Sammie": System.out.println("What's up " + student + "?"); break; default: System.out.println("I dont even know you dog :/"); break; }
i am finding this series incredibly useful. im doing engineering in university and im required to learn java. they really skipped over most of the important basics. im at the start of semester 2 and they only just wrote out a list of all primitive types where they expected us to use them like pros throughout semester 1 lol
if (name == "caleb") { System.out.println("Weclome my man!"); String Access = "yes"; } if (name == "clare") { System.out.println("Go away"); String Access = "no"; } else { System.out.println("Try again later"); String Access = "no"; // I added the variable Access to simulate what it would probably be in real life to show the rest of your code that // the user does or does not have Access to your program. // He was right about it having more Syntax. Although from my knowledge of python this code makes more sense // to me than the one he described in the video.
How to make use of switch without the break statement. You can ask the user how many things should be excecuted (cases). If you put the cases in reversed order: case 3: do this (no break), case 2: do that (no break), case 1: do some other stuff (no break). If the user enters 1, only thing one is done. If the user enters 2, then thing number 2 and then 1 is done. If the user enter 3, all three things are done.
Omgoodness After all this time of struggling, I finally understand. Thank you Caleb System.out.println(happy face emoji with one tear); Lmaoo. Here is my if statement of my own tho ;P. System.out.println("What is your name?"); Scanner scnr = new Scanner(System.in); String name = scnr.nextLine();
It seems to me like break is just serving a simular function to a closing curly brace. It is different in certain ways of course, but both of them seem to be some kind of closing syntax.
07:33 the code ( i didn't tried this in an ide ) if (name == "caleb"){System.out.println("Go Awaw!!"); else if (name == "clare"){System.out.println("Go Awaw!!");} else {try again later}
Scanner scanner = new Scanner(System.in); System.out.println("What is your name?"); String name = scanner.nextLine(); String Rubel = new String("Zaglul"); if(name.equals(Rubel)) { System.out.println("Welcome " + Rubel + " we are waiting for you"); }else { System.out.println("Please try agai later"); }
I'm not sure if this will work on other programs but IntelliJ fixed my switch state with multiple cases to this: switch (name) { case "johnny", "appleseed" -> System.out.println("big apple"); default -> System.out.println("go smoke some appleseeds"); } looks like you can use -> as a substitute for :.
Scanner scanner = new Scanner(System.in); String Caleb = "Caleb", Clare = "Clare"; String input = scanner.nextLine(); String name = input.toLowerCase(); if (name.equals(Caleb.toLowerCase()) || name.equals(Clare.toLowerCase()) { System.out.println("Go away"); } else { System.out.println("Try again later"); } I wonder if I messed anything up. Half of this I learned today, and half I learned like 8 years ago lol.
Here is my full code for this episode, including for the switch statement and an if statement version. I will be using characters from a story of mine for names in this. :) package ep018to0XX; import java.util.Scanner; public class Ep021SwitchStatement { public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("What's your name?"); String name = scanner.nextLine();
switch (name) { default: System.out.println("Hmm, your not on the list, so I can't let you in. Have a nice day though!"); break; case "Sam": case "Nealy": System.out.println("Welcome in my dude!"); break; case "Rjinder": System.out.println("GO AWAY YOU MONSTER!!!"); break; }
if (name.equals("Sam") || name.equals("Nealy")) { System.out.println("Welcome in my dude!"); } else if(name.equals("Rjinder") ) { System.out.println("GO AWAY YOU MOSTER!!!"); } else { System.out.println("Hmm, your not on the list, so I can't let you in. Have a nice day though!"); }
How would you make it possible to also add the integer "1" as a command for System.out.println("Loads file"); in this switch case below? System.out.print("Name the command: "); String command = input.nextLine();
switch (command) { case "load file": System.out.println("Loads file"); break;
import java.util.Scanner; public class MySweetProgram { public static void main(String[] args) { //method System.out.println("What's your name?"); Scanner scanner = new Scanner(System.in); String name = scanner.nextLine(); if(name.contentEquals("Caleb")) { System.out.println("Welcome my man"); } else if (name.contentEquals("Clare")) { System.out.println("Go away"); } else { System.out.println("Try again later"); } } } Was so proud of this lmao
//Here is the code I made during this video: import java.util.Scanner; class Hello { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); String statement = "Write your name!"; System.out.println(statement.toUpperCase()); String name = scanner.nextLine(); if ((name.toLowerCase().equals("caleb")) || (name.toLowerCase().equals("clare"))) { System.out.println(" MAKE A CLARE FACE REVEAL!");
package hello; import java.util.Scanner; public class MySweetProgram { public static void main(String[] args) { //method System.out.println("What is your name?");
Scanner scanner = new Scanner(System.in); String name = scanner.nextLine();
if(name.equals("Caleb")) { System.out.println("Welcome my man"); } else if(name.equals("Clare")) { System.out.println("go away"); } else { System.out.println("Try Again Later"); } } } I think there is a better way to do this but this works
if (dogYears == 0) { // Like case 0 // Print 0..14 years } else if (dogYears == 1) { // Like case 1 // Print 15 years } ... else if (dogYears == 5) { // Like case 5 // Print 37 years } else { // Like default case // Print unknown }
When I get interviewed on pramp what I should choose out of the list there if I've done java only based on your channel, such as a data science, front end, back end, system design or something else?
Hi i have a question can we use the “toLowerCase” method with the switch statements, i try but couldn’t figure it out, i know we can do it with the “if else” but im not sure about this one??
Hmm I guess it depends on how you look at it. to me, it does not *really* count as fall through! If we take a look at functionality over syntax, fall through is equivalent in nature to having an if statement with an else-if and an else, where the the if block is executed followed by the else-if block and else block (logically impossible). Having two case labels is the equivalent of having an || in an if condition. The condition can be met in more than one circumstance yet only one block is executed. Even languages such as C# will not allow fall through and will give a compiling error yet having two case labels is completely fine. Either way, fall through (executing code in a switch block without it being followed by a break) rarely is recommended. It’s the cause of too many errors and should be avoided when possible. Regardless, I think we are splitting hairs. Let’s move on to something more important, like pretty much anything 🙂
import java.util.Scanner; public class MySweetProgram { public static void main(String[] args) { System.out.println("HWat's your name? "); Scanner scanner = new Scanner(System.in); String name = scanner.nextLine(); if (name.equals("John Amend-all") || name.equals("Robin")) { System.out.println("Welcome to the Forest!"); } else if (name.equals("Gisborne")) { System.out.println("Gow away a sort of evil!"); } else { System.out.println("Go away!"); } } }
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner input = new Scanner(System.in); do { System.out.println("What is your name? "); String hard_copy = input.nextLine(); String name = hard_copy.toLowerCase(); if (name.equals("caleb") || name.equals("claire")) { System.out.println("Go away!"); }else {
System.out.println("Try again later"); } } while (true); } }
My Masterpiece: package hello; import java.util.Scanner; public class MyFirstJavaProgram { public static void main(String[] args) {
System.out.println("What is your name boy?"); Scanner scanner = new Scanner(System.in); String name = scanner.nextLine();
if(name.equals("Edward") || name.equals("Mufasa")) { System.out.println("Thats a baller ass name bro! Can we be friends?"); } else { System.out.println("IT DOESNT MATTER WHAT YOUR NAME IS!!"); }
if (name.equals("Calob")) { System.out.println("Wellcome cool!"); } else if(name.equals("Clare")) { System.out.println("You have no access"); } else { System.out.println("Try later again!"); }
if (name.equals("Caleb") || name.equals("Clare")) { //I tried using (name == "Caleb" || name == "Clare") but doesnt work //cause it's object types and compare the memory location System.out.println("Stash Away hehe"); } else { System.out.println("Try again some other time dont forget to wear mask tho bye"); }
if (name.equals("caleb")) { sysout "welcome"; // too lazy to write it down fully.. you know what i mean! } else if (name.equals( "clare")) { sysout "go away"; } else { sysout "try again later"; }
import java.util.Scanner; public class User { public static void main (String[] args){ Scanner mainScanner = new Scanner(System.in); System.out.println("What is your name?"); String name = mainScanner.nextLine(); if (name.toLowerCase().equals("caleb") || name.toLowerCase().equals("clare")){ System.out.println("Go away"); } else { System.out.println("Welcome!"); } } }
import java.util.Scanner; public class CalebClaire_if { public static void main(String[] args) { System.out.println("What is your name?"); Scanner sc = new Scanner (System.in); String name = sc.nextLine(); if (name.toLowerCase().equals("caleb") || name.toLowerCase().equals("claire")) { System.out.println("Go away."); return; } else { System.out.println("Welcome!"); } System.out.println("Have a nice day, " + name + "!"); } }
import java.util.Scanner; public class exercise { public static void main(String[] args) { System.out.println("Please enter your name : "); String Name; Scanner scan = new Scanner(System.in); Name = scan.nextLine();
if(Name.equals("Caleb")) { System.out.println("Welcome my man"); }else if(Name.equals("Claire")) { System.out.println("Go away"); }else { System.out.println("Try again Later"); } } }
Learn Javascript - bit.ly/JavaScriptPlaylist
Learn Java - bit.ly/JavaPlaylist
Learn C# - bit.ly/CSharpTutorialsPlaylist
Learn C++ - bit.ly/CPlusPlusPlaylist
Learn C - bit.ly/CTutorialsPlaylist
thanks for the video.
I got this as the "if" statement version. I have changed a few things but please let me know if the concept is correct!
public static void main(String[] args) {
System.out.println("What is your name?");
String name1 = "Caleb";
String name2 = "Monica";
Scanner scanner = new Scanner (System.in);
String name = scanner.nextLine();
if(name.equals(name1)) {
System.out.println("You are male");
}
else if(name.equals(name2)) {
System.out.println("You are female ");
}
}
}
if (name.equals("caleb") || name.equals("clare")){
System.out.println("Go away');
}
else{
System.out.println("Try again later");
}
That's my solution, i hope it has no errors!
On the "Go away" there is an error because of the single quote at the end ;) You should close it with double quotes.
You are THE BEST JAVA TEACHER I ever had !!! Thank you for all tutorials !!!
absolutely
definitely if it wasn't for Caleb id fail my exam. Couldn't understand anything until I researched on UA-cam!
Clare is like a recurring theme throughout these videos and I've never wanted to know more about someone's life until I watched these videos. Who tf is Clare?? We need to know!
Wow! Pramp?!?? I've never been able to do well in an interview... But with Pramp, I'll get off the streets for sure!
Buy now (its free)! 😉
Props to you Caleb. Before I watched this video I had never even heard of the switch statement, let alone used it in coding. Thanks to you I now feel like I know exactly how to use it with confidence. You explained it brilliantly in 8 minutes. Thank you! :)
I love your videos, Caleb! I'm taking Java Programming this semester in college, so this is extremely helpful!
if (name.equals("Caleb")) {
System.out.println("Welcome my man");
} else if (name.equals("Clare")) {
System.out.println("Go away");
} else {
System.out.println("Try again later");
}
Thank you so much for these tutorials!
Woowww, I'm glad that I'm finally learning something. I also made a switch statement for fun. Here y'all go:
System.out.println("Who are you?");
Scanner scnr = new Scanner(System.in);
String student = scnr.nextLine();
switch(student){
case "Melissa":
System.out.println("Welcome" + '\t' + student + "!");
break;
case "Sammie":
System.out.println("What's up " + student + "?");
break;
default:
System.out.println("I dont even know you dog :/");
break;
}
i am finding this series incredibly useful. im doing engineering in university and im required to learn java. they really skipped over most of the important basics. im at the start of semester 2 and they only just wrote out a list of all primitive types where they expected us to use them like pros throughout semester 1 lol
if (name == "caleb") {
System.out.println("Weclome my man!");
String Access = "yes";
}
if (name == "clare") {
System.out.println("Go away");
String Access = "no";
}
else {
System.out.println("Try again later");
String Access = "no";
// I added the variable Access to simulate what it would probably be in real life to show the rest of your code that // the user does or does not have Access to your program.
// He was right about it having more Syntax. Although from my knowledge of python this code makes more sense // to me than the one he described in the video.
just like c++, i think knowing c++ made all these series easier.
does it apply also in learning java first and c++? vice versa? i'm learning java first and maybe after this i'm going with c++ lol
@@tomcat9761 I think because c++ is a harder language to learn where there are a lot of complex concepts.
once you learn a lanuage you can apply it to the others,
me knowing a bit of every coding language and doing this type of code from 2 years in java script
lol
you made me under stand this on a another level not boring
The way you introduce pramp in different ways every episode makes me laugh so hard and make me guess how will you do it on the next ep lol
tama..haha tsaka chill lang siya magturo lol
I Like your approach of teaching Java Programming. I appreciate you for investing your time to educate people like us. Thanks, Keep 'em coming! :)
How to make use of switch without the break statement. You can ask the user how many things should be excecuted (cases). If you put the cases in reversed order: case 3: do this (no break), case 2: do that (no break), case 1: do some other stuff (no break). If the user enters 1, only thing one is done. If the user enters 2, then thing number 2 and then 1 is done. If the user enter 3, all three things are done.
Omgoodness After all this time of struggling, I finally understand. Thank you Caleb
System.out.println(happy face emoji with one tear); Lmaoo. Here is my if statement of my own tho ;P.
System.out.println("What is your name?");
Scanner scnr = new Scanner(System.in);
String name = scnr.nextLine();
if(name.equals("Johnny")){
System.out.println("What's Poppin :P");
}
else if(name.equals("Tommy")){
System.out.println("Heyyyy"+ '\t' + name);
}
else{
System.out.println("Nah fam, you gotta go, GoodBye.");
}
I think u can go to dub for Disney's movies with that voice of promoting Pramp
It seems to me like break is just serving a simular function to a closing curly brace. It is different in certain ways of course, but both of them seem to be some kind of closing syntax.
07:33 the code ( i didn't tried this in an ide )
if (name == "caleb"){System.out.println("Go Awaw!!");
else if (name == "clare"){System.out.println("Go Awaw!!");}
else {try again later}
Day 2 🙌 Done 21 out of 100, 79 more to go let's go! 🔥
Scanner scanner = new Scanner(System.in);
System.out.println("What is your name?");
String name = scanner.nextLine();
String Rubel = new String("Zaglul");
if(name.equals(Rubel)) {
System.out.println("Welcome " + Rubel + " we are waiting for you");
}else {
System.out.println("Please try agai later");
}
import java.util.Scanner;
public class MySweetProgram {
public static void main(String[] args) { // method
System.out.println("What's ya name?");
Scanner scanner = new Scanner(System.in);
String guess = scanner.nextLine();
String name = "Manuel";
if(guess.equals(name))
{
System.out.println("Welcome my man!");
} else if(guess.equals("Jane"))
{
System.out.println("You ain't no girl!");
} else
{
System.out.println("Try again.");
}
}
}
(Thanks for these vids Caleb, you're awesome!)
Is it a good idea to combine Caleb and Clare though 7:19
basically
if are actual conditions where as switch needs "'EXACT'" statement
if (name.equals("Caleb")) {
// Code
} else if (name.equals("Clare")) {
// Code
} else {
// Code
}
hahaha for once i actually enjoy learning how to program you make it fun...and you nailed the Ad
I'm not sure if this will work on other programs but IntelliJ fixed my switch state with multiple cases to this: switch (name) {
case "johnny", "appleseed" -> System.out.println("big apple");
default -> System.out.println("go smoke some appleseeds");
}
looks like you can use -> as a substitute for :.
thanks for the knowladge
this code works in vs code
Scanner scanner = new Scanner(System.in);
String Caleb = "Caleb", Clare = "Clare";
String input = scanner.nextLine();
String name = input.toLowerCase();
if (name.equals(Caleb.toLowerCase()) || name.equals(Clare.toLowerCase()) {
System.out.println("Go away");
} else {
System.out.println("Try again later");
}
I wonder if I messed anything up. Half of this I learned today, and half I learned like 8 years ago lol.
Thank u so much Caleb! Lots of love😚
Here is my full code for this episode, including for the switch statement and an if statement version. I will be using characters from a story of mine for names in this. :)
package ep018to0XX;
import java.util.Scanner;
public class Ep021SwitchStatement {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("What's your name?");
String name = scanner.nextLine();
switch (name)
{
default:
System.out.println("Hmm, your not on the list, so I can't let you in. Have a nice day though!");
break;
case "Sam":
case "Nealy":
System.out.println("Welcome in my dude!");
break;
case "Rjinder":
System.out.println("GO AWAY YOU MONSTER!!!");
break;
}
if (name.equals("Sam") || name.equals("Nealy"))
{
System.out.println("Welcome in my dude!");
} else if(name.equals("Rjinder") )
{
System.out.println("GO AWAY YOU MOSTER!!!");
} else
{
System.out.println("Hmm, your not on the list, so I can't let you in. Have a nice day though!");
}
}
}
import java.util.Scanner;
//Prompts the user to input their name, if it is 'Syandiswa', the app opens
public class TaskOnIfStatements {
public static void main(String[] args) {
System.out.println("What is your name?");
Scanner scanner=new Scanner(System.in);
String name= scanner.nextLine();
if(name.equals("Syandiswa"))
{
System.out.println("Hi, Welcome");
}
else if(name.equals("Mandisa"))
{
System.out.println("Hi, Welcome.");
}
else
{
System.out.println("Go away");
}
}
}
import java.util.Scanner;
//Prompts the user to input their name, if it is 'Syandiswa' or Mandisa, the app opens
public class TaskOnIfStatements {
public static void main(String[] args) {
System.out.println("What is your name?");
Scanner scanner=new Scanner(System.in);
String name= scanner.nextLine();
if(name.equals("Syandiswa")|| name.equals("Mandisa"))
{
System.out.println("Hi, Welcome");
}
else
{
System.out.println("Go away");
}
}
}
excellent teaching Caleb
System.out.println("What is your name?");
Scanner scanner=new Scanner(System.in);
String name=scanner.nextLine();
if(name.equals("caleb")||name.equals("clare")){
System.out.println("Go Away");
}
else{
System.out.println("Try Again Later");
}
This is the best intro ever💀😂
"MySweetProgram" got me deadd
How would you make it possible to also add the integer "1" as a command for System.out.println("Loads file"); in this switch case below?
System.out.print("Name the command: ");
String command = input.nextLine();
switch (command) {
case "load file":
System.out.println("Loads file");
break;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter name: ");
String name = scanner.nextLine();
if(name.equals("Caleb")) {
System.out.println("Welcome my man");
} else if(name.equals("Clare")) {
System.out.println("Go away");
} else {
System.out.println("Try again later");
}
import java.util.Scanner;
public class MySweetProgram {
public static void main(String[] args) { //method
System.out.println("What's your name?");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if(name.contentEquals("Caleb"))
{
System.out.println("Welcome my man");
} else if (name.contentEquals("Clare"))
{
System.out.println("Go away");
} else
{
System.out.println("Try again later");
}
}
}
Was so proud of this lmao
if (name.equals("Caleb"))
{
System.out.println("Welcome Caleb ");
return;
}
else if (name.equals("Clare"))
{
System.out.println("Welcome Clare");
return;
}
else
{
System.out.println("Go Away");
return;
//Here is the code I made during this video:
import java.util.Scanner;
class Hello {
public static void main (String[] args) {
Scanner scanner = new Scanner(System.in);
String statement = "Write your name!";
System.out.println(statement.toUpperCase());
String name = scanner.nextLine();
if ((name.toLowerCase().equals("caleb")) || (name.toLowerCase().equals("clare"))) {
System.out.println("
MAKE A CLARE FACE REVEAL!");
}else {
System.out.println("
comment #WhoIsClare");
}
}
}
Is it possible to use "and" or 'or' in the case statement
package hello;
import java.util.Scanner;
public class MySweetProgram {
public static void main(String[] args) { //method
System.out.println("What is your name?");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if(name.equals("Caleb")) {
System.out.println("Welcome my man");
}
else if(name.equals("Clare")) {
System.out.println("go away");
}
else {
System.out.println("Try Again Later");
}
}
}
I think there is a better way to do this but this works
if (dogYears == 0) { // Like case 0
// Print 0..14 years
}
else if (dogYears == 1) { // Like case 1
// Print 15 years
}
...
else if (dogYears == 5) { // Like case 5
// Print 37 years
}
else { // Like default case
// Print unknown
}
What's the deal with Clare?
if ( name.equals(username) )
{
System.out.println("welcome");
}
else if ( name.equals(username) )
{
System.out.prinln("go away");
}
else
{
System.out.println("try again");
}
Lots of thanks
what do you use as an editor
import java.util.Scanner;
public class FirstProgram {
public static void main(String[] args) {
System.out.println("Enter Name");
Scanner scanner = new Scanner(System.in);
String x = scanner.nextLine();
if(x.equals("Caleb")|| x.equals("Clare")) {
System.out.println("Go Away");
}
else{
System.out.println("Try Again Later");
}
}
}
Everyone: Karren
Caleb: Clare
if(name.contentEquals("Clare"))
{
System.out.println("go away");
return;
}
else if(name.contentEquals("Caleb"))
{
System.out.println("go away");
} else
{
System.out.println("try again later");
}
When I get interviewed on pramp what I should choose out of the list there if I've done java only based on your channel, such as a data science, front end, back end, system design or something else?
Algorithms and data structures!
Thank you, Appreciate it! You are the best!
You literally said there was no good use for fall-through, then proceeded to immediately use fall-through.
Hi i have a question can we use the “toLowerCase” method with the switch statements, i try but couldn’t figure it out, i know we can do it with the “if else” but im not sure about this one??
I don’t think you can. I think 😏
You might be able to set Caleb and Claire as variable and then do Caleb.toLowerCase and vice versa
if name = caleb
system.out.println("Welcome my man")
else if name = clare
system.out.println("go away")
else
sysem.out.println(""Try again later")
Fall-through has lots of use cases. It shows up a lot in code. That's why it exists.
It should not be used.
I don’t really consider having two case labels together fall through.
@@codebreakthrough Except that's exactly what it is.
Hmm I guess it depends on how you look at it. to me, it does not *really* count as fall through!
If we take a look at functionality over syntax, fall through is equivalent in nature to having an if statement with an else-if and an else, where the the if block is executed followed by the else-if block and else block (logically impossible).
Having two case labels is the equivalent of having an || in an if condition. The condition can be met in more than one circumstance yet only one block is executed.
Even languages such as C# will not allow fall through and will give a compiling error yet having two case labels is completely fine.
Either way, fall through (executing code in a switch block without it being followed by a break) rarely is recommended. It’s the cause of too many errors and should be avoided when possible.
Regardless, I think we are splitting hairs.
Let’s move on to something more important, like pretty much anything 🙂
with this entrance i am going to sign up for Pramp
good video men
I was looking for @Clare in comments, did not find anyone.
Good video though.
public static void main(String[] args) {
System.out.println("What's Your Name?: ");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if (name.equals("Jilly")) {
System.out.println("Welcome!");
}
else if (name.equals("Mia")) {
System.out.println("HELL NO!");
}
else {
System.out.println("Really?");
}
import java.util.Scanner;
public class MySweetProgram {
public static void main(String[] args) {
System.out.println("HWat's your name?
");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if (name.equals("John Amend-all") || name.equals("Robin")) {
System.out.println("Welcome to the Forest!");
} else if (name.equals("Gisborne")) {
System.out.println("Gow away a sort of evil!");
} else {
System.out.println("Go away!");
}
}
}
Maybe leave the break out if you want to fall through with a generic message for all and a personal message for certain users.
The reason I'm here is so I can finally stop slopping around.
If(name.equals(“Caleb”) || name.equals(“Clare”){
System.out.println(“go away”);
}
Hey!! 😡
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
do {
System.out.println("What is your name? ");
String hard_copy = input.nextLine();
String name = hard_copy.toLowerCase();
if (name.equals("caleb") || name.equals("claire"))
{
System.out.println("Go away!");
}else {
System.out.println("Try again later");
}
} while (true);
}
}
My Masterpiece:
package hello;
import java.util.Scanner;
public class MyFirstJavaProgram {
public static void main(String[] args) {
System.out.println("What is your name boy?");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if(name.equals("Edward") || name.equals("Mufasa")) {
System.out.println("Thats a baller ass name bro! Can we be friends?");
} else {
System.out.println("IT DOESNT MATTER WHAT YOUR NAME IS!!");
}
} // end of main method
} // end of program
if(name.equals("Caleb")|| name.equals("Clare")
System.out.println("Go away");
else
System.out.println("Try again later");
if (name.equals("Calob")) {
System.out.println("Wellcome cool!");
}
else if(name.equals("Clare")) {
System.out.println("You have no access");
}
else {
System.out.println("Try later again!");
}
if (name.equals("Caleb") || name.equals("Clare")){
System.out.println("Go away");
}else {
System.out.println("Try again later");
}
if (name.equals("Caleb") || name.equals("Clare")) { //I tried using (name == "Caleb" || name == "Clare") but doesnt work //cause it's object types and compare the memory location
System.out.println("Stash Away hehe");
}
else {
System.out.println("Try again some other time dont forget to wear mask tho bye");
}
//My posting of the 'switch' code, using 'if' statement
import java.util.Scanner;
public class ifPlay {
public static void main(String[] args) {
System.out.println("What is your name?");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
String myName = "Joe";
String herName = "Carol";
if(name.compareTo(myName) == 0) {
System.out.println("Welcome");
}else if(name.compareTo(herName) == 0) {
System.out.println("Go Away");
}else {System.out.println("Try again");
}
scanner.close();
}
}
Ay My Man squadW
Scanner scanner = new Scanner (System.in);
String name = scanner.nextLine();
If (name.equals("Caleb") || name.equals("Clare") ) {
System.out.println("Go away");
}
Else {
System.out.println("Try again later");
}
No "break" is needed in the default case, as it is always the last statement in the switch. (y)
import java.util.Scanner;
public class tutoriall {
public static void main(String[] args) {
System.out.println("What's your name");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if(name.equals("FirtsName") || name.equals("SecondName"))
{
System.out.println("Go away!");
} else
{
System.out.println("Try later!");
}
}
}
import java.util.Scanner;
public class Java{
public static void main (String [] args){
System.out.println("Whats your name?");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if(name.toLowerCase().equals("mohammed")){
System.out.println("Welcome");
}
else if(name.equals("Claire")){
System.out.println("go away");
}
else if(name.toLowerCase().equals("claire")){
System.out.println("Nice try, go away");
}
else{
System.out.println("eh");
}
}
}
if (name.equals("caleb")) {
sysout "welcome"; // too lazy to write it down fully.. you know what i mean!
} else if (name.equals( "clare")) {
sysout "go away";
} else {
sysout "try again later";
}
import java.util.Scanner;
public class User {
public static void main (String[] args){
Scanner mainScanner = new Scanner(System.in);
System.out.println("What is your name?");
String name = mainScanner.nextLine();
if (name.toLowerCase().equals("caleb") || name.toLowerCase().equals("clare")){
System.out.println("Go away");
}
else {
System.out.println("Welcome!");
}
}
}
I will never allow anyone to call me Clare again! :D :D
1 Caleb disliked this video LOL! :D
Bro has beef with the name Clare
import java.util.Scanner;
public class CalebTutorial21 {
public static void main( String [] args) {
Scanner scanner = new Scanner(System.in);
System.out.println(" Whats your name?");
String name = scanner.nextLine();
if (name.equals("Akash")) {
System.out.println(" Hi " + name + " Welcome to Java ");
} else if (name.equals("Sunny")) {
System.out.println( " Hi " + name + " Welcome to Java ");
} else {
System.out.println(" Welcome to Hell");
}
}
}
public class hmm{
public static void main(String[] args){
method();
}
private void method(){
Scanner sc = new Scanner(System.in);
String name = sc.next().toLowerCase();
if(name.equals("claire") || name.equals("caleb")){
System.out.println("Sorry, you're not allowed entrance, goodbye!");
}else{
System.out.println("Try again :)");
method();
}
}
}
import java.util.Scanner;
public class CalebClaire_if {
public static void main(String[] args) {
System.out.println("What is your name?");
Scanner sc = new Scanner (System.in);
String name = sc.nextLine();
if (name.toLowerCase().equals("caleb") || name.toLowerCase().equals("claire")) {
System.out.println("Go away.");
return;
}
else {
System.out.println("Welcome!");
}
System.out.println("Have a nice day, " + name + "!");
}
}
is claire your ex? did she hurt you during the break up?
Please do a Tutorial for Java FX
And please can you use IntelliJidea
Because I can use a bunch of ad on there including a GUI editor😁😁😁
Yanderedev disliked this video
Pramp. (*-ω-)
if ("Caleb" == name || "Clare" == name) {
sout("Go away");
} else {
sout("Try again later");
}
import java.util.Scanner;
public class MySweetPtogram {
public static void main(String[] args) { //method
System.out.println("What's your name?");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
if (name.equals("Caleb")|| name.equals("Clare"))
{
System.out.println("Go away");
}
else
{
System.out.println("Try again later");
}
}
}
import java.util.Scanner;
public class exercise
{
public static void main(String[] args)
{
System.out.println("Please enter your name : ");
String Name;
Scanner scan = new Scanner(System.in);
Name = scan.nextLine();
if(Name.equals("Caleb"))
{
System.out.println("Welcome my man");
}else if(Name.equals("Claire"))
{
System.out.println("Go away");
}else
{
System.out.println("Try again Later");
}
}
}