Rajeswary Govindasamy
program that uses while loops to perform the following steps :
1 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners

Write a program that uses while loops to perform the following steps : a. Prompt the use to input two integers : FirstNum and secondNum.( FirstNum must be less than secondNum.) b. Output all the odd numbers between firstNum and secondNum inclusive. c. Output the sum of all the ven number between FirstNum and secondNum inclusive. d. Output all the numbers and their squares between 1-10. e. Output the sum of the squares of all the odd numbers between firstNum and secondNum inclusive f. Output all the uppercase letters.

(java coding: pls help me)

September 20, 2012 at 5:51 PM

```import java.util.*;
public class NumberExample{
public static void main(String[]args){
int sum=0,sumSquares=0;
int num1=0,num2=0;
Scanner input=new Scanner(System.in);
System.out.print("Enter First Number: ");
num1=input.nextInt();

System.out.print("Enter Second Number: ");
num2=input.nextInt();

if(num1>num2){
num1=input.nextInt();
}
else{
System.out.println("Odd Numbers: ");
while(num1 <= num2) {
if(num1%2 != 0) {
System.out.println(num1);
sumSquares+=(num1*num1);
}
if(num1%2 == 0) {
sum+=num1;
}
num1++;
}
System.out.println("Sum Of Even Numbers: "+sum);
System.out.println("Numbers and their squares between 1 and 10");
int i=1;
while(i <= 10) {
System.out.println(i+"    "+(i*i));
i++;
}
System.out.println("Sum Of square of odd Numbers: "+sumSquares);
}
}
}
```