Social Sciences, asked by chaurasiyalalit58, 4 months ago

write a method that receives a number and returns the cube of the number​

Answers

Answered by anjuyogeshyadav
2

Answer:

How can I write a method in Java that receives a number and returns the cube of the number?

As you have already discovered, simple numeric input in Java is not as simple as it is in BASIC or C. (Or am I misunderstanding the question to assume that you want to input a number, then return the cube of the number?

In BASIC, I could simply say: INPUT number

In JAVA, I need to use several statements to do the same thing. Below, I describe statements I used in a program I wrote while learning JAVA:

import before the public statements allows you to use predefined utility statements in the methods themselves:

import java.util.Scanner;

a new Scanner device statement allows you to input entire numbers:

.

Similar questions