Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public static void Question2()
  2. {
  3.     double math;
  4.     String s;
  5.     Scanner sqrt = new Scanner(System.in);
  6.  
  7.     do
  8.     {
  9.         System.out.print("Enter a number: ");
  10.         math = sqrt.nextDouble();
  11.         System.out.println("The square root of "+math+ " is "+Math.sqrt(math));
  12.         System.out.println("The cube root of "+math+" is "+Math.cbrt(math));
  13.         System.out.println("The square of "+math+" is "+Math.pow(math,2));
  14.         System.out.println("the cube of "+math+" is "+Math.pow(math, 3));
  15.  
  16.         System.out.println("Input another number? `y` / `n`");
  17.         s = sqrt.next();
  18.     }
  19.     while (s == "y");
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement