public static void main(String[] args) throws Exception {
InputStreamReader streamReader = new InputStreamReader(System.in);
BufferedReader bufferedReader = new BufferedReader(streamReader);
String word = bufferedReader.readLine();
int input = Integer.parseInt(bufferedReader.readLine());
displayStringNtimes(word, input);
}
public static void displayStringNtimes(String word, int input) {
while (input > 0) {
System.out.println(word);
input--;
}
}
code is working. Please i need an improvement on it. Thanks
Archived
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
26 December 2018, 23:24
The code is fine, though for loops are designed to use counters.
+1
Angeget
27 December 2018, 10:45
Thanks very much. The code with for loop is even shorter.
Thanks and be blessed.
0
Maryem Vickers
5 August 2020, 18:00
^w^ he's a helper. See, he helped me once not long ago! XD
0