Computer Science, asked by iasngew, 11 months ago

a java programs to print a number along with its square and cube​

Answers

Answered by shujaat82
0


share
Java Programming Exercies
Java Data Type Exercises: Reads a number and display the square, cube, and fourth power

Last update on September 19 2019 10:38:00 (UTC/GMT +8 hours)


Java Data Type: Exercise-8 with Solution

Write a Java program that reads a number and display the square, cube, and fourth power.

Test Data
Input the side length value: 15

Sample Solution:

Java Code:

import java.util.Scanner;
public class Exercise8 {

public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input the side length value: ");
double val = in.nextDouble();

System.out.printf("Square: %12.2f\n", val * val);
System.out.printf("Cube: %14.2f\n", val * val * val);
System.out.printf("Fourth power: %6.2f\n", Math.pow(val, 4));
}
}

Copy
Sample Output:

Input the side length value: 15
Square: .2f
Cube: .2f
Fourth power: 50625.00
Flowchart:

Flowchart: Java Data Type Exercises - Reads a number and display the square, cube, and fourth power
JavaCode Editor: brackets no1
Answered by syiemjohn84
0

Answer:

Import java. util .*;

Class total

{

public static void main (String [] arts)

{

Scanner sc = new Scanner (System. in);

int length, sqare cube;

System . out . print (``\enter length");

length=sc. next Int();

System. out . print (``\enter square");

square=sc . next Int();

System. out. print (``\ enter cube");

}

}

Similar questions