Computer Science, asked by priya2004, 11 months ago

write a java program to print square and cube of any user given number using method ((void square( int n), void cube( int n))

Answers

Answered by amannishad0512p5zxh6
5
import java.util.*;

class Number

{

public void square(int n)

{

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

}

public void cube(int n)

{

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

}

public static void main()

{

Scanner sc=new Scanner(System.in);

Number ob=new Number();

System.out.println("Enter your number");
int a=sc.nextInt();

ob.square(a); // call square function

ob.cube(a); // to call cube function

}

}

Hope it will help you@ Priya

For more java doubts follow me

amannishad0512p5zxh6: Takki input le sakke
amannishad0512p5zxh6: Lekin aap upar nichhe kar sakte ho
amannishad0512p5zxh6: Chahe kuch bhi pehle likho
amannishad0512p5zxh6: Now you got
amannishad0512p5zxh6: Ask here till what you not got??
priya2004: thanks for clarifying
amannishad0512p5zxh6: Yaar thanks kis baat kaa
amannishad0512p5zxh6: Thanks toh mujhe apko karna chahiye
amannishad0512p5zxh6: Apki wajah se mera revision hua
amannishad0512p5zxh6: Thanku so much
Similar questions