+ 1

Error message in java

Hello everyone, hope you are having a great day so far! I have been given this assignment to do but I keep getting this error in Java. To sum up the question, they have asked me to check the numbers between an Integer and print "COMP" if the number is a multiple of the given integer. "1161" if its a multiple of 5 and "COMP1161" if it is a multiple of both numbers. Here is my code: public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ int num; Integer IntObj = new Integer(int num); for(i=1; i <=num; i++){ if (i % 3 == 0 && i % 5 == 0){ System.out.println("COMP1161"); } else if(i % 3 == 0){ System.out.println("COMP"); } else if(i % 5 == 0){ System.out.println("1161"); } else{ System.out.println(i); } } } } Here are the error messages: Solution.java:12: error: '.class' expected Integer IntObj = new Integer(int num); ^ Solution.java:12: error: ';' expected Integer IntObj = new Integer(int num); ^ 2 errors Every comment is much appreciated. Thanks in advanced

29th Mar 2019, 2:25 PM
Leo Hunter
Leo Hunter - avatar
1 Resposta
0
Had you created a class called Integer as it does not pre-exist.
26th Nov 2019, 3:42 PM
︻╦╤─♦งēຖ໐๓♠彡
︻╦╤─♦งēຖ໐๓♠彡 - avatar