Computer Science, asked by rajithaplodhaworldsc, 4 months ago

Write a menu driven program in java that outputs the result of the following evaluations based on the
number entered by the user.
1. Absolute value of a number
2. Square root of a number
3. Random numbers between 0 and 1

Answers

Answered by Wiley8705
1

Explanation:

Square and Square Root

The square of a number is that number times itself. In other terms, when we multiply an integer by itself we call the product the square of the number. Mathematically, the square of a number is given as,

Square of n = n*n

For example, the square of number 4 is 4*4 = 16

The square root is just the opposite of the square. The square root of a number, n, is the number that gives n when multiplied by itself. Mathematically, the square root of a number is given as,

Square Root of n = √n

Now that you know what square and square root of a number are, let’s see different ways to calculate them in Java.

How to Square a Number in Java

You can square a number in Java in two different ways:

Multiply the number by itself

Call the Math.pow function

Method1: Square a number by multiplying it by itself

Here’s a Java Program to square a number by multiplying it by itself.

Answered by CopyThat
7

Answer:

JAVA :-

Explanation:

import java.util.*;

class Brainly

static void main()

{

double n,c,a,s,r;

Scanner sc=new Scanner(System.in);

System.out.println(“Enter a number:”);

n=sc.nextDouble();

c=Math.cbrt(n);

a=Math.abs(n);

s=Math.sqrt(n);

r=Math.random();

System.out.println(“Cube Root=”+c);

System.out.println(“Absolute=”+a);

System.out.println(“Square Root=”+s);

System.out.println(“Random number=”+r);

}

}

Similar questions