- 4
Java's beginner question about task
I am a complete beginner at learning Java. Could You help me with this task, please? Methods You are creating a robot, "Welcomer 2000", that never fails to greet a single person it encounters. You provide the number of people that will enter the room, and the robot will shout "Welcome" that number of times. The program you are given already takes a number as input and calls the method according provided count. The issue is that the method is incomplete. Fix it. Sample Input 2 Sample Output Welcome! Welcome!
10 odpowiedzi
+ 2
import java.util.Scanner;
public class Main {
public static int numberOfPeople;
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
numberOfPeople = read.nextInt();
for (int i = 0; i < numberOfPeople; i++) {
welcome();
}
}
public static void welcome() {
//complete the method
System.out.println("Welcome!");
}
}
+ 1
Very good Dariusz Jenek . Just a little change
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
System.out.println("Welcome");
}
}
//Try this one
0
Hi Dariusz Jenek you can't just ask anyone to solve for you if you don't do it yourself, you should first try it and after many failures you should ask it to someone providing them your code, that would make you a better programmer.
0
Complete the course to explore more
0
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
System.out.println(numberOfPeople * "Welcome");
}
}
0
import java.util.Scanner;
public class Main {
public static int numberOfPeople;
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
numberOfPeople = read.nextInt();
for (int i = 0; i < numberOfPeople; i++) {
welcome();
}
}
public static void welcome() {
//complete the method
System.out.println("Welcome!");
}
}
Try this one!
0
Tx
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int numberOfPeople = read.nextInt();
//Please Subscribe to My Youtube Channel
//Channel Name: Fazal Tuts4U
for (int i = 0; i < numberOfPeople; i++) {
welcome();
}
}
public static void welcome() {
System.out.println("Welcome!");
}
}
0
It not working
0
import java.util.Scanner;
public class Main {
public static int numberOfPeople;
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
numberOfPeople = read.nextInt();
for (int i = 0; i < numberOfPeople; i++) {
welcome();
}
}
public static void welcome() {
//complete the method
System.out.println("Welcome!");
}
}