Computer Science, asked by sukritidhungana96, 3 days ago

write a program that asks the user to input a number and displays, square, square root and cube of the number​

Answers

Answered by samanwitapaul07
1

Answer:

import java.util.*;

class number{

void accept()

{

Scanner sc=new Scanner(System.in);

double n;

do{

System.out.print ("Enter a number : ");

n=sc.nextDouble();

}while(n<=0);

double sq = n*n;

double sqrt=Math.sqrt(n);

double cb=Math.pow(n,3);

System.out.println("Square of "+n+" is "+sq);

System.out.println("Square root of "+n+" is "+sqrt);

System.out.println("Cube of "+n+" is "+cb);

}

public static void main(String args[])

{

number ob = new number();

ob.accept();

}

}

Similar questions