# Thread: Output all the numbers and their squares between 1 and 10.

1. Member Join Date
Aug 2011
Posts
4
Rep Power
0

## Output all the numbers and their squares between 1 and 10. Write a program that uses while loops to perform the following steps:
a. Promp the user to input two integers: firstNum and secondNum.(firstNum
must be less than secondNum.)
b. Output all the odd nummbers between firstNum and secondNum.
c. Output the sum of all even numbers between firstNum and secondNum.
d. Output all the numbers and their squares between 1 and 10.
e. Output the sum of the squares of all the odd numbers between firstNum and
secondNum.

I'm working on d and e, but i dont know how to show the square of the Output all the numbers and their squares between 1 and 10.  Reply With Quote

2. ## Re: Output all the numbers and their squares between 1 and 10.

You do know that i*i is the square of a number i, do you? You also know how to print both of them? Here's how:

Java Code:
` System.out.println(i+" "+i*i);`
You also know how to create a loop that iterates from 1 to 10, do you? Here's how:

Java Code:
`for (int i= 1; i <= 10; i++)`
It doesn't take rocket science to combine the two ...

kind regards,

Jos  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•