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. 🙏❤️
4 ответов
+ 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.
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.
0
How? I want the program to print the value of the string and the integer... How to do that.?
0
Big thanks