0
Please help me with this code
Please help me to solve the problem with this code https://code.sololearn.com/ci3njX8brM4P/?ref=app
8 Answers
+ 2
Scanner scan = new Scanner(System.in);
// not SystemIn
+ 2
Hi.....! it's:
Scanner scan = new Scanner(System.in);
and not
Scanner scan = newScanner(Systemln);
the method /**next()**/
retains the cursor in the same line after reading the input.
replace it by /**nextLine()**/
+ 2
replace this line /**String religion = scan.next();**/ by
String religion = scan.nextLine(); and it will show worksip
+ 1
Thanks but why do the worship do not show
+ 1
Ok but I want to show that worship
+ 1
/**try this code. remember to split multiple input in separate line when you press run your input should be like that :
mousa
muslin
brique **/
import java.util.Scanner ;
public class Answer
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("what is your name");
String name = scan.nextLine();
System.out.println("what is your religion");
String religion = scan.nextLine ();
if (religion .equals ("Muslim"))
{ System.out.println("which Mosque do you go to");
}
else
{
System.out.println("which Church do you go to");
}
String worship = scan.nextLine();
System.out.println("Your name is "+ name);
System.out.println("Your religion is "+ religion);
System.out.println("You worship at "+ worship);
}
}
0
I want to make the worship in two words
0
next() method accept single word and input pointer stays in same line after reading input.
nextLine() accept entire line of input (any number of words), until new line character feed. so goes to next line after reading..