In: Computer Science
In a file called Conversions.java, write a program that:
Asks the user to enter a double number.
Stores that number into a variable called z.
Casts variable z into an integer, and stores the result into a variable called z1.
Creates a variable z2, and sets it equal to the integer closest to z.
Creates a variable z3, and sets it equal to the floor of z.
Creates a variable z4, and sets it equal to the ceiling of z.
Prints out the values of z1, z2, z3, z4, using the same format as shown below.
For example: if the user enters 3.9, your program output should look like this:
Please enter a double number: 3.9
z cast into an int becomes 3.
z rounded becomes 4.
The floor of z is 3.
The ceiling of z is 4.
w Java User Input (Scanner class X Online C++ Compiler - online ed x C in A File Called Conversionsjava, Java Examples Math Examples x + -ox → C onlinegdb.com/online_ct_compiler Run Debug Stop Stare Sive Dessulify Language Jeva OnlineGDB beta crne compless and debugger lor c++ Main.java code.comde.run. debug. share. DE 3 Welcome to GDB Online. 4 GDR online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, 5 CN, VI, Swift, Pascal, Fortran, Ilaskell, objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. 6 Code, Compile, Run and Debug online from anywhere in world. My Projects Learn Programming Programming Questions We are Hiring Sign Up 18 Login f y + 19.5K 9 import java.util.; 10 public class Conversions 11- public static void main(String[] args) { Scanner sc - new Scanner(System.in); double 2; System.out.print("Please enter a double number: "); z=5c.nextDouble(); int zl (int); int 22 - (int) Math.round(2); int z3 =(int)Math.floor(2); int 24-(int) Math.ceil(z); System.out.println("z cast into an int becomes "+z1); System.out.println("z rounded becomes " z2); System.out.println("The floor of z is "+z3); System.out.println("The ceiling of z is "+24); GOT AN OPINION? SHORE AND GET BALASE) Rakuten AP Have fun taking surveys and get paidi ADS VIA CARBON Please enter a double number:3.9 2 cart into an int. DACOMAR 3 2 rounded becomes The floor of z is 3 The ceiling of zis 4 About FACI Hog. Terms of Use Contact Us - GUH Tutorial - Credits 2016-2019 GDB Online ... Program finished with exit code 0 Pre ENTER LO exit 116.j Type here to search A G - 256 AM ENG 9/11/2019 21
w Java User Input (Scanner class X Online C++ Compiler - online ed x C in A File Called Conversionsjava, Java Examples Math Examples x + -ox → C onlinegdb.com/online_ct_compiler Run Debug Stop Stare Sive Dessulify Language Jeva OnlineGDB beta crne compless and debugger lor c++ Main.java code.comde.run. debug. share. DE 3 Welcome to GDB Online. 4 GDR online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, 5 CN, VI, Swift, Pascal, Fortran, Ilaskell, objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. 6 Code, Compile, Run and Debug online from anywhere in world. My Projects Learn Programming Programming Questions We are Hiring Sign Up 18 Login f y + 19.5K 9 import java.util.; 10 public class Conversions 11- public static void main(String[] args) { Scanner sc - new Scanner(System.in); double 2; System.out.print("Please enter a double number: "); z=5c.nextDouble(); int zl (int); int 22 - (int) Math.round(2); int z3 =(int)Math.floor(2); int 24-(int) Math.ceil(z); System.out.println("z cast into an int becomes "+z1); System.out.println("z rounded becomes " z2); System.out.println("The floor of z is "+z3); System.out.println("The ceiling of z is "+24); GOT AN OPINION? SHORE AND GET BALASE) Rakuten AP Have fun taking surveys and get paidi ADS VIA CARBON Please enter a double number:3.9 2 cart into an int. DACOMAR 3 2 rounded becomes The floor of z is 3 The ceiling of zis 4 About FACI Hog. Terms of Use Contact Us - GUH Tutorial - Credits 2016-2019 GDB Online ... Program finished with exit code 0 Pre ENTER LO exit 116.j Type here to search A G - 256 AM ENG 9/11/2019 21
We were unable to transcribe this image
w Java User Input (Scanner class X Online C++ Compiler - online ed x C in A File Called Conversionsjava, Java Examples Math Examples x + -ox → C onlinegdb.com/online_ct_compiler Run Debug Stop Stare Sive Dessulify Language Jeva OnlineGDB beta crne compless and debugger lor c++ Main.java code.comde.run. debug. share. DE 3 Welcome to GDB Online. 4 GDR online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, 5 CN, VI, Swift, Pascal, Fortran, Ilaskell, objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. 6 Code, Compile, Run and Debug online from anywhere in world. My Projects Learn Programming Programming Questions We are Hiring Sign Up 18 Login f y + 19.5K 9 import java.util.; 10 public class Conversions 11- public static void main(String[] args) { Scanner sc - new Scanner(System.in); double 2; System.out.print("Please enter a double number: "); z=5c.nextDouble(); int zl (int); int 22 - (int) Math.round(2); int z3 =(int)Math.floor(2); int 24-(int) Math.ceil(z); System.out.println("z cast into an int becomes "+z1); System.out.println("z rounded becomes " z2); System.out.println("The floor of z is "+z3); System.out.println("The ceiling of z is "+24); GOT AN OPINION? SHORE AND GET BALASE) Rakuten AP Have fun taking surveys and get paidi ADS VIA CARBON Please enter a double number:3.9 2 cart into an int. DACOMAR 3 2 rounded becomes The floor of z is 3 The ceiling of zis 4 About FACI Hog. Terms of Use Contact Us - GUH Tutorial - Credits 2016-2019 GDB Online ... Program finished with exit code 0 Pre ENTER LO exit 116.j Type here to search A G - 256 AM ENG 9/11/2019 21
4 1 import java.util.Scanner; 2 public class Main 3- { public static void main(String[] args) { 5 Scanner sc = new Scanner(System.in); double Z; 7 System.out.print("Please enter a double number:"); 8 z=sc.nextDouble(); 9 int z1=(int)z; 10 int z2 = (int) Math.round(z); int z3 =(int)Math.floor(z); 12 int z4=(int) Math.ceil(z); System.out.println("z cast into an int becomes "+z1); 14 System.out.println("z rounded becomes "+z2); System.out.println("The floor of z is "+z3); 16 System.out.println("The ceiling of z is "+24); 17 } 18 } 11 13 input Please enter a double number:3.9 Iz cast into an int becomes 3 z rounded becomes 4 The floor of z is 3 The ceiling of z is 4 ... Program finished with exit code o Press ENTER to exit console. I
import java.util.Scanner;
public class Conversions
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double z;
System.out.print("Please enter a double number:");
z=sc.nextDouble();
int z1=(int)z;
int z2 = (int) Math.round(z);
int z3 =(int)Math.floor(z);
int z4=(int) Math.ceil(z);
System.out.println("z cast into an int becomes "+z1);
System.out.println("z rounded becomes "+z2);
System.out.println("The floor of z is "+z3);
System.out.println("The ceiling of z is "+z4);
}
}