Computer Science, asked by riya1342, 1 year ago

Input a number and display its square if it is less than 50 ,else display its cube.plz its urgent JAVA PROGRAM

Answers

Answered by nain31
15
 \huge{ANSWER}

Java is a machine independent language which can work on any platform. Its an object oriented programming which stress on object rather than data.

The main parts while doing Java programming are package, Class ,input variables, condition updating.

The following programming is done by io package of Java.

CODING :---

import Java. io. *;

class check

{

public static void main(String args[])throws Exception

{

DataInputStream in = new DataInputStream(System.in);

int n, i , s=0;

System. out. println("Enter any number ");

n=Interger.parseInt(in.readLine());

s=n*n;

if(n<=50)

System. out. println("The square of number is"+s);

else

System. out. println("The cube of number is"+(n*n*n));

}

}


OUTPUT :-

1)-n=5

s=5×5
=25
Since its less than 50

The square of number is 25.

2)-n=9

s=9*9=81
Since, the square is more than 50.

The cube of number is 729

riya1342: to seekh lo
ParamPatel: TO MAIN KYA KARU
ParamPatel: PYTHON SIKHLE
ParamPatel: EK KAAM KAR ANDROID PROGRAMMING KARLE
tausif59: abhi ye sab ke liye time nhi hai lol !!
riya1342: plz dont disturb here
nain31: no more comments please :)
ParamPatel: ISS answer ko report hi kardo
ParamPatel: best idea
tausif59: bhai !! Bhai !! baat maanle uski :(
Answered by wwwalison8888a
6

Listen sq nd cube could be taken out by n*n and n*n*n respectively without using math function.

Attachments:
Similar questions