Code problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Code problem

I am getting an error saying “compliation error” and I don’t know why Here’s the link https://code.sololearn.com/cWXqAf5KfevM/#java

10th Nov 2019, 2:04 PM
tayjiri149
2 Answers
+ 5
Always use equals method for string value comperishon
10th Nov 2019, 6:28 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 4
import java.util.Scanner; class Playground { public static void main(String[ ] args) { System.out.println("Random sequence"); wordSequence(); } public static void wordSequence(){ //scanner Scanner sc = new Scanner(System.in); char userin = sc.next().charAt(0); //check user input int num = 0; if (userin == 'a'){ num = 5; }else if (userin == 'b'){ num = 6; }else if (userin == 'c'){ num = 7; }else if (userin == 'd'){ num = 8; }else if (userin == 'e'){ num = 9; }else if (userin == 'f'){ num = 10; }else if (userin == 'g'){ num = 11; }else if (userin == 'h'){ num = 12; } //draw sequence for (int n=num;n<100000;n=n-1+n-2){ System.out.println(n); } } } Atleast this works, learn java properly
10th Nov 2019, 2:25 PM
Avinesh
Avinesh - avatar