0
Friendly Robot help with the method
public static void welcome() {; There's no output and it's expected to have "Welcome!" Help Please?
12 Respostas
+ 2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int numberOfPeople = read.nextInt();
for (int i = 0; i < numberOfPeople; i++) {
welcome();
}
}
public static void welcome() {
//complete the method
}
}
+ 1
really confused, i though it was easy but nothing is easy in programming....
+ 1
peter
Your code is so off track that no-one knows how to respond.
Java Tutorial 2.1 offers this possibility.
class MyClass {
public static void main(String[ ] args) {
System.out.println("Welcome");
}
}
But you mentioned using a method?
Can you be more specific with what you are attempting.
+ 1
The following might help you, but you must understand how methods work.
A method is created as a self contained bit of code which only produces a result when called.
Think of it as a little machine that only makes something when it is turned on.
So first you must make the machine.
Then when you are running your code in main(), you must call its function to get the output.
for (int i = 0; i < numberOfPeople; i++) {
welcome(); //calls method
}
}
// this section creates the method
public static void welcome() {
System.out.println("Welcome");
}
+ 1
this is an empty method:
public static void welcome() {
//complete the method
}
//complete the method
means: here is the place where you have to write the rest (body) of method
+ 1
Thank you all for helping me, really appericate it đ€
+ 1
I have tried to print the text but it's showing error.
+ 1
Done it in another way
0
but I'm confused where to put and complete the method
0
The last method where it says
//complete the method
// this section creates the method
public static void welcome() {
System.out.println("Welcome");
}
0
Yes i have tried but now it's showing no symbol found.
0
public static void welcome() {
System.out.println(âWelcome!â);
}