+ 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"); } } }

15th Aug 2016, 1:44 AM
KARTHI KHEYEN (IMPULSEKARTHI)
KARTHI KHEYEN (IMPULSEKARTHI) - avatar
6 ответов
+ 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"); } } }
15th Aug 2016, 2:57 AM
Tiger
Tiger - avatar
+ 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"); }
15th Aug 2016, 3:02 AM
Angela Liu
Angela Liu - avatar
+ 1
the "if" next to the else is not needed..:)
15th Aug 2016, 12:31 PM
Vijaya Bharathy V R
Vijaya Bharathy V R - avatar
+ 1
the "if" next to the else is not needed..:)
15th Aug 2016, 12:31 PM
Vijaya Bharathy V R
Vijaya Bharathy V R - avatar
+ 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"); } } }
15th Aug 2016, 12:34 PM
Vijaya Bharathy V R
Vijaya Bharathy V R - avatar
+ 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"); } } }
15th Aug 2016, 5:24 PM
Ravi Kumar
Ravi Kumar - avatar