Write the lines of code not the whole program that will Prom
Write the lines of code (not the whole program) that will: Prompt the user to input two integers: firstNum and secondNum (assume firstNum is less then second Num). Output all the odd numbers between firstNum and secondNum using a while loop. Output the sum of all the even numbers between firstNum and secondNum using a for loop. Output all the numbers and their squares between 1 and 10 using a do...while loop.
Solution
a)
int firstNum,secondNum;
Scanner input = new Scanner(System.in);
System.out.println(\"Enter 2 integers first number less than second number\");
firstNum=input.nextInt();
secondNum=input.nextInt();
b)
int i=firstNum;
while(i<=secondNum){
// if the number is not divisible by 2 then it is odd
if(i %2 !=0){
System.out.print(\"Odd numbers are \"+i);
}
i++;
}
c)
for(int i=firstNum; i <= secondNum; i++){
// if the number is divisible by 2 then it is even
if( i % 2 == 0)
{
System.out.print(\"Even Numbers are \"+i);
}
}
d)
int i=1;
do{
System.out.print(\"numbers are \"+i);
int j;
j=i*i;
System.out.print(\"Square numbers are \"+j);
i++;
}while(i<=10)
