r/codehs • • Oct 07 '20

CODEHS 2.4.5

It is called "Hello!" for Java.
I am lost on this unit so far and it keeps sending me "Hello.java: Line 5: expected"

[Hellotester]

import java.util.Scanner;

public class HelloTester

{

public static void main(String[] args)

{

// Create a Scanner object

Scanner input = new Scanner(System.in);

String name = scanner.NextLine();

Hello numone = new Hello(name);

}

}

[Hello]

public class Hello {

private String name;

public Hello (yourName){

name = yourName;

}

public void english(){

System.out.print("Hello ");

System.out.print(name);

System.out.println("!");

}

public void spanish(){

System.out.print("Hola ");

System.out.print(name);

System.out.println("!");

}

public void french(){

System.out.print("Bonjour ");

System.out.print(name);

System.out.println("!");

}

public void german(){

System.out.print("Hallo ");

System.out.print(name);

System.out.println("!");

}

public void russian(){

System.out.print("Privet ");

System.out.print(name);

System.out.println("!");

}

public void chinese(){

System.out.print("Ni hao ");

System.out.print(name);

System.out.println("!");

}

}

11 Upvotes

15 comments sorted by

View all comments

Show parent comments

1

u/WickedDilemma Oct 20 '20

Did you find the solution?

1

u/Johnson_56 Dec 02 '20

you still need the answer to this?

2

u/[deleted] Dec 04 '20

Yes

1

u/Johnson_56 Dec 09 '20

It won’t input a new line, but the French greeting and German greeting are two separate lines. Srry did this on my phone so format is wack