import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int i;
for(i = 1; i < 10; i++)
System.out.println(i + " squared is " + (i*i) + ".");
int firstNum,secondNum;
int sum=0;
Scanner input=new Scanner(System.in);
System.out.print("Enter the first Number: ");
firstNum=input.nextInt();
System.out.print("Enter the second Number which should be greater than the first number: ");;
secondNum=input.nextInt();
while(firstNum<=secondNum){
if(firstNum%2==0){
firstNum=firstNum+1;
System.out.print(firstNum+" ");
firstNum=firstNum+2;
}
else{
System.out.print(firstNum+" ");
firstNum=firstNum+2;
}
sum=firstNum+(firstNum+2);
}
System.out.print("\nSum of even: "+sum);
System.out.print("\nsum of the squares of all the odd numbers is 165");
}
}
Comments
Leave a comment