Basically what you need to do is ask the user to enter a name, then you use that name in a sentence that says that person loves you and print it 10 times. So if the user enters Albert, you need to print "Albert loves me." 10 times, each time in its own line. Here is my solution, but note that I used Scanner to capture the user input instead of BufferedReader because that is what I am used to:
package en.codegym.task.jdk13.task04.task0439;
//import java.io.BufferedReader;
//import java.io.InputStreamReader;
import java.util.Scanner;
/*
Chain letter
*/
public class Solution {
public static void main(String[] args) throws Exception {
Scanner user = new Scanner(System.in);
String name = user.nextLine();
user.close();
String out = name + " loves me.";
for(int i = 0; i < 10; i++){
System.out.println(out);
}
}
}
I had a problem with this. took me a minute to figure out which loop was running which part.
but i thought for some reason the the first loop was continuously running tell the System.out.println()
but it doesn't first outer loop controls the inner loop printing the 8 or whatever. understanding this was hard.
I love it was clueless on for but was able to figure out how they work while using them then practice yes test can sometimes be touch but who cares not like there counting right; lol love it here
Cr4zySl4ckrLevel 6, United States of America, United States
16 March 2023
What is in the red box is the output wanted not "The program should display numbers on the screen"
Not the first task when I get to the right result, but the test is not passed :( after running the code from the solution the test is passed, although the result is just the same as mine.
GO TO FULL VERSION