+ 1

X and y addition divided by a whole number z

Here is my try package assignment; public class dave { public static void main(String[] args) { int = x,y,z float x = 4.70; float y = 3.30; int = x+y/whole numer System.out.println("Sum of digits = "x+y/sum); { if ("float"x+y"/z"= to a whole number < five print true if ("float"x+y"/z" is > than five print false } }

22nd Jul 2021, 8:41 PM
Dav Alf
3 Respostas
0
https://code.sololearn.com/cA6a0a5a8A1a ^Play around with that to get the feel for what you're trying to do. Once you've progressed with Java further, you can use a scanner object to obtain input from the user instead of hardcoding the values. public class Program { 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 " + result); if(result > 5) { System.out.println("Result is greater than 5!"); } else { System.out.println("Result is less than or equal to 5!"); } } } ::::OUTPUT:::: Result is 4.0 Result is less than 5!
22nd Jul 2021, 8:54 PM
Jakko Jak
Jakko Jak - avatar
0
Jakko Jak Still it can't run help me identify the error package csit; public class assignment { 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 or equal to 5!"); } } }
22nd Jul 2021, 9:48 PM
Dav Alf
0
Remove "package csit;" and it'll run fine. sum was renamed to result, so that should be updated also.
23rd Jul 2021, 1:40 PM
Jakko Jak
Jakko Jak - avatar