- 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!

13th Jun 2021, 10:46 AM
Dariusz Jenek
Dariusz Jenek - avatar
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!"); } }
25th Jan 2022, 4:34 AM
Abdirahman Farah
Abdirahman Farah - avatar
+ 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
13th Jun 2021, 2:03 PM
Atul [Inactive]
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.
13th Jun 2021, 10:49 AM
Eashan Morajkar
Eashan Morajkar - avatar
0
Complete the course to explore more
13th Jun 2021, 10:54 AM
Atul [Inactive]
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"); } }
13th Jun 2021, 1:10 PM
Dariusz Jenek
Dariusz Jenek - avatar
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!
28th Jun 2021, 5:54 AM
Fachridan Tio Mu'afa
Fachridan Tio Mu'afa - avatar
0
Tx
18th Aug 2021, 12:36 PM
Vitalijs Riznikovs
Vitalijs Riznikovs - avatar
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!"); } }
4th Sep 2021, 4:42 AM
Fazal Haroon
Fazal Haroon - avatar
0
It not working
11th Nov 2022, 6:10 AM
Praveen Kumar S
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!"); } }
12th Nov 2022, 10:57 AM
Pooja Patel
Pooja Patel - avatar