+ 1
rectify error in below code pls
public class Program { public static void main(String[] args) { int age = 25; int money = 100; if (age > 18 && money > 500) { System.out.println("Welcome!");} { elseif System.out.println("Wronge"); } } }
6 Réponses
+ 1
try the below:
public class Program {
public static void main(String[] args) {
int age = 25;
int money = 100;
if (age > 18 && money > 500) {
System.out.println("Welcome!");
} else{
System.out.println("Wronge");
}
}
}
+ 1
Following the if statement you should either have an else statement instead of the else if statement or a condition after the else if statement (or both).
Ex.
if(age >18 && money >500){
System.out.println("Welcome!");
}
else if(age == 18){
System.out.println("text");
}
else{
System.out.println("other text");
}
+ 1
the "if" next to the else is not needed..:)
+ 1
the "if" next to the else is not needed..:)
+ 1
try the below:
public class Program
{
public static void main(String[] args)
{
int age = 25;
int money = 100;
if (age > 18 && money > 500)
{
System.out.println("Welcome!");
}
else
{
System.out.println("Wronge");
}
}
}
+ 1
if next to else iss not required try the following code
public class Program {
public static void main(String[] args) {
int age = 25;
int money = 100;
if (age > 18 && money > 500) {
System.out.println("Welcome!");
}
else {
System.out.println("Wronge");
}
}
}