Computer Science, asked by muliraveendrareddy, 1 year ago

PROGRAM TO INPUT A NO. . IF THE NO, IS EVEN PRINT ITS SQUARE OTHERWISE PRINT ITS CUBE

Answers

Answered by harindersaini2pcf8vf
5

Hey there !

The answer for your question for JAVA (not with Scanner class)  is as follows :-

class abc

{

   void main(int n)

     {

        if (n%2 == 0)

        System.out.println("The number is even. It's square is " + (n*n));

        else

        System.out.println("The number is odd. It's cube is " + (n*n*n))

    }

}





Hope it helps :-)






harindersaini2pcf8vf: Please mark as brainliest if it really helped...please...please
harindersaini2pcf8vf: If you need variable description then please tell, i'll type it .
harindersaini2pcf8vf: Please mark as brainliest...if it helped...please...please
Answered by priyadharshansharma
3

public class evorod

{

public static void main (int n)

{

if (n%2==0)

System.out.println("No is even. Square is=" +(n*n));

else

System.out.println("No is odd. Cube is ="(n*n*n));

}

}


This is the answer

Similar questions