0

Where i made a mistake??Please Help

package Program; import java.util.*; public class Perfect_Number { public static void main(String args []) { String Choice ; int x=1;int y=1; if(x-y==0) { int a; Scanner in =new Scanner(System.in); System.out.println("Enter the value to be checked :"); a=in.nextInt(); int b;int c = 0; for (b=1;b<=a;b++) { if (a%b==0) { c=b+c; System.out.println("The Factors of "+a+" are " + b); } } if (c==a) { System.out.println("It is a perfect number"); } else { System.out.println("It is not a perfect number"); } System.out.println("Type Yes to restart of No to Quit"); Choice=in.next(); if (Choice=="Yes") { y=0; } } } }

29th Jul 2017, 4:43 PM
Abhi
Abhi - avatar
4 Respuestas
+ 9
This code resolves the errors. https://code.sololearn.com/crW3FuAXpCM0/?ref=app What were the errors for? - You can't declare or import a package here in the code playground. It isn't supported. - Don't only use in.next() for taking a String input, use in.nextLine() instead. It's a better choice to have!
29th Jul 2017, 4:51 PM
Dev
Dev - avatar
+ 8
@Abhi the code playground doesn't support simultaneous multiple inputs so it's better to put multiple inputs into two different/separate lines.
29th Jul 2017, 5:20 PM
Dev
Dev - avatar
+ 1
Yeah got my mistake but i can't restart it? Can Anyone Help Me?
29th Jul 2017, 4:56 PM
Abhi
Abhi - avatar
0
thanks
29th Jul 2017, 5:20 PM
Abhi
Abhi - avatar