Static void Q15print the numbers from 1 to 40 including 1 an
Static void Q15(){//print the numbers from 1 to 40 (including 1 and 40) except if the number is even print \"even\" instead//of the number and if the number is greater than 25 print \">25\" instead of the number. For number that//are both even and greater than 25 print \"even> 25\" for (int n = 1; n 25){System.out.printIn(\">25\");} else if (n%2 == 0 && n > 25){System.out.printIn(\"even > 25\");} else{System.out.println(n);}}}
Solution
As per your question,
(i) if number<25 and number%2==0 ,then output should be EVEN.
(II) if number>25 and number%2==0, then output should be EVEN>25.
(iii) if number<25 and number%2!=0 then output should be NUMBER(LIKE 1,3,5..).
(IV) if number >25 and number%2!=0 then output should be >25.
your code should like this.
for (int n=1;n<=40;n++){
if(n%2==0 && n<25){
system.out.println(\"even\");
else if(n%2==0 && n>25){
system.out.println(\"even>25\");
}
else if( n>25){
system.out.println(\">25\");
}
else{
system.out.println(n);
}
}
}
