Asked by Trish Goal
This was the assignment: If the first parameter is less than the second parameter add the two and print the result 10 times. THIS PROGRAM IS IN JAVA.
I did everything but I can't figure out how to print the result as a loop 10 times.
public static void main(String args[])
{
int x1;int x2;
x1=5;
x2=8;
if (x1<x2)
System.out.println(x1+x2);
}
}
How would I print the result as a loop ten times?
Thanks!
I did everything but I can't figure out how to print the result as a loop 10 times.
public static void main(String args[])
{
int x1;int x2;
x1=5;
x2=8;
if (x1<x2)
System.out.println(x1+x2);
}
}
How would I print the result as a loop ten times?
Thanks!
Answers
Answered by
Writeacher
There is no need to keep reposting the same question. Please pay attention to the directions on the Post a New Question webpage:
<b>Homework Posting Tips
...
Please be patient. All tutors are volunteers, and sometimes a tutor may not be immediately available. Please be patient while waiting for a response to your question.</b>
<b>Homework Posting Tips
...
Please be patient. All tutors are volunteers, and sometimes a tutor may not be immediately available. Please be patient while waiting for a response to your question.</b>
Answered by
Steve
You really need to learn how to consult your java documentation, or at least use google. I did a search for "java loop" and found this in 5 seconds:
while( x < 20 ) {
System.out.println("value of x : " + x );
x++;
}
I'm sure you can adapt it to your needs.
while( x < 20 ) {
System.out.println("value of x : " + x );
x++;
}
I'm sure you can adapt it to your needs.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.