+ 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
3 Respuestas
+ 5
Always use equals method for string value comperishon
+ 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