0

Guys I have this issue and it's disturbing me it can't run

public static void main(String[] args) { double x = 4.7; double y = 3.3; int z = 2; double result; result = (x+y)/z; System.out.println("Result is" + sum); if (result > 5);{ system.out.println("Result is greater than 5!"); }else{ system.out.println("Result is less than 5!"); } } }

25th Jul 2021, 6:41 PM
Dav Alf
2 Answers
+ 3
1. The main method needs to be inside a class. (Guessing it was cut off) 2. Your first output, before the if statement, refers to the variable 'sum' instead of 'result'. 3. You have a semicolon ';' just after the if statement conditions closing parentheses ')'. Remove it. 4. Both of the put put statements inside the if and else are referring to system instead of System (Capitalization matters, members are case sensitive). After fixing these issues your code does run.
26th Jul 2021, 12:27 AM
ChaoticDawg
ChaoticDawg - avatar
0
Actually in System class your S initial letter should be capital in Second and third print statement also declear one class
25th Jul 2021, 7:21 PM
A S Raghuvanshi
A S Raghuvanshi - avatar