0

How can I print a string and a number together and the result of that allows to print the variable?

Hello World! https://code.sololearn.com/cS97288S5G1P/?ref=app As you can see in my code, I want to print question1 Answer1 Question2 Answer2 Without writing the number until 100... I want to do a loop and add the number of the loop to a string. Thank you for helping me.! Don't forget to upvote please. 🙏❤️

16th Apr 2020, 8:04 AM
Maximilien
Maximilien  - avatar
4 Respostas
+ 3
to print out "Question" and it's number, just do this System.out.println("Question" +i) ; where i is an integer (your loop iterator) ligne 9 and 10 of your code should be System.out.println("Question"+i); System.out.println("Answer"+i); and you forgot to close the main function curly brace "}" after the for loop.
16th Apr 2020, 8:45 AM
John Robotane
John Robotane - avatar
0
you can use a string array to store the questions and another to store answers. to print them, you'll just have to iterate over those arrays.
16th Apr 2020, 8:12 AM
John Robotane
John Robotane - avatar
0
How? I want the program to print the value of the string and the integer... How to do that.?
16th Apr 2020, 8:13 AM
Maximilien
Maximilien  - avatar
0
Big thanks
16th Apr 2020, 9:06 AM
Maximilien
Maximilien  - avatar