Комментарии:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean isTrue = false;
System.out.print("Enter a number between 1 and 10: ");
while (!isTrue) {
int num = input.nextInt();
if (num < 1 || num > 10) {
System.out.println(num + " is not between 1 and 10. Please try again.");
} else {
System.out.println(num + " is between 1 and 10. Thank you!");
isTrue = true;
}
}
}
}
2morrow I have exam from Java And I found this channel very helpful. I will study after exams too ❤thanks Neso
ОтветитьGreatest
ОтветитьGreat! Thank you <3
ОтветитьYou are a legend. Please continue making useful videos
ОтветитьI solved it in this way:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int number = '\0';
Scanner s = new Scanner(System.in);
do {
System.out.println("Enter a number!");
number = s.nextInt();
if(number > 0 && number < 11) {
System.out.println(number + " is between 1 and 10.");
} else {
System.out.println(number + " is not between 1 and 10. Try again!");
}
} while (!(number > 0 && number < 11));
System.out.println("Game over");
}
}
sir why you are using "||" (or)operator and not using "&&" operator in while() condition.
ОтветитьBelow is my stupid code:
import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
{
Scanner input = new Scanner(System.in);
System.out.println("Enter your favorite number between 1 and 10");
int n1 = input.nextInt();
while(n1<1 || n1>10){
System.out.println("you're not listening, try again");
n1=input.nextInt();
}
System.out.println("ok good");
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Give num 1-10: ");
int inp = scanner.nextInt();
if (inp <= 10 && inp >= 0) {
System.out.println("Inp was " + inp);
} else {
System.out.println("Inp was not in range of 1 and 10");
}
}
}
int user = 0;
while (!(user > 1 && user < 10)) {
user = s.nextInt();
if (user > 1 && user < 10) {
System.out.println(user + " is between 1 and 10");
} else
System.out.println(user + " is not betwen 1 and 10");
System.out.println("TRY AGAIN");
}
public static void main (String args[])
{
Scanner num=new Scanner(System.in);
while (true)
{
System.out.println("enter the number between 1 and 10");
int n=num.nextInt();
if (n>10 || n<0)
{
System.out.println("please enter the correct number");
n=num.nextInt();
}
else
{
System.out.println(n +" "+"is between 1 and 10 thanks!");
break;
}
}
package ayushi;
import java.util.Scanner;
public class Main {
public static void main(String[] arg) {
Scanner intput = new Scanner(System.in);
System.out.println("enter your number:");
int a =intput.nextInt();
while (1<a && a<10){
System.out.println(a + "is in between 1 and 10");
a =intput.nextInt();
}
System.out.println(a + "is in not between 1 and 10");
}
}
يعطيك العافيه 😍😍
ОтветитьWhy if I do not write this line in the while body, it becomes a loop? Or how is it possible that simply writing this line, it stops the while loop? n = s.nextInt();
Ответитьthank you!
ОтветитьExcellent lecture. This is my code, which worked, continuing to watch your solution:
public class Main {
public static void main(String[] args) {
System.out.print("enter a number between 1 and 10: ");
Scanner number = new Scanner(System.in);
int f = number.nextInt();
while (f<1 || f>10) {
System.out.print(f + " is not between 1 and 10. Try again: ");
f = number.nextInt();
}
System.out.println(f + " is between 1 and 10. Thanks!");
}
}
what if we enter 1 or 10 ?
it shows us this no is between 1 to 10
cant we use another variable i with n?
ОтветитьThanks
Ответитьimport java.util.Scanner;
public class Program
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int num;
System.out.println("Enter a number between 1-10:");
num = in.nextInt();
if(num<=10){
System.out.println("Nice " num + " is between 1-10 thanks");
}
else{
System.out.println(num + " is not 1 - 10 Try again dumbass");
}
}
}
I think you should use && inside the while loop
ОтветитьThe way Neso Academy explaining concepts is Excellent.
Ответитьthank you
Ответить😎 A1 content, just subbed! Did you check followsm . c o m?! It’s the best way to promote your videos!
Ответитьimport java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a numbre between 1=10");
int a = sc.nextInt();
while (true) {
if (a < 11 && a > 0) {
System.out.println("Thanks");
break;
}
else {
System.out.println("Try again");
a=sc.nextInt();
}
}
}
}
please upload videos fast
ОтветитьPlz made video on Feedback Amplifier
ОтветитьHello neso academy, I am waiting for Data structure course. Please tell me release date.
ОтветитьRealness
thanks very much for all the JAVA tutorials
East or west our neso java sir is the best....
ОтветитьAwesome 🔥🔥🔥❤️🔥🔥❤️🔥❤️🔥
Ответить