a.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the int variable and assign the value
Integer i = new Integer(“23”);
//Print the required data fields
System.out...
b.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the int variable and assign the value
Integer i = new Integer(23);
//Print the required data fields
System.out...
c.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the int variable and assign the value
Integer i = new Integer.valueOf(“23”);
//Print the required data fields
System.out...
d.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the int variable and assign the value
Integer i = new Integer.parseInt(“23”,8);
//Print the required data fields
System.out...
e.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the double variable and assign the value
Double d = new Double();
//Print the required data fields
System.out...
f.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the double variable and assign the value
Double d = new Double.valueOf(“23.45”);
//Print the required data fields
System.out...
g.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the int variable and assign the value
int i = (Integer.valueOf(“23”)).intValue();
//Print the required data fields
System.out...
h.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the double variable and assign the value
Double d = (Double.valueOf(“23.4”);
//Print the required data fields
System.out...
i.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
//Declare the int variable and assign the value
int i = (Double.valueOf(“23”)).intValue();
//Print the required data fields
System.out...
j.
Explanation of Solution
//Class definition
public class test {
// Define main function
public static void main(String[] args) {
/*Declare the double variable and assign the
Value*/
String s = (Double.valueOf(“23.4”).toString();
//Print the required data fields
System...
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- 7. Given the following code, what initial values for num will cause an error during execution? int mystery(int num) { if (num 0) == return 0; else if (num 0 B. num > -100 and num < 0 C. num < 0 D. None of these will cause an error. 8. For the code in the previous problem, what will happen if the initial value of num is invalid?arrow_forwardint test(int *x, int y){ x=&y; return(*x+y); } int main(void) { int x=1, y=6; test(&y, x); printf("%d %d %d", x, test (&y,x),y); return 0; } 1 2 6arrow_forwardGiven the snippet of code: int al = {2, 4, 6, 8, 10, 12), x, *p = a; x = *(p + 4)+1; printf("%d", x); What will be the value of x after the following statement is executed? 13 5 12 11arrow_forward
- 3. After execution of the following code, what is stored in valueNum?All variables are using data type int. Note that num1=3, num2=5, and num3=7.if (num2> num3) if (num1 > num2) valueNum =num2; else valueNum =num3; else if (num2 > num3) valueNum =num1; else valueNum = num3; Record the output screen display: Explain your answerarrow_forwarddef square(x): return x * X def halve(x): return x // 2 def twice(f,x): """Apply f to the result of applying f to x >>> twice (square,3) 81 >>> twice (square, 4) 256 >>> twice (halve, 32) 8 >>> twice (halve, 80) 20 *** YOUR CODE HERE ***"arrow_forward3. int x =9 ;display the address of the variable x? Answer:arrow_forward
- Given the following declaration: int x; int* p; Which of the following expressions is allowed? Select one: a. p = x; b. p = &x; %3D C. p = *x; d. x = p;arrow_forwardExercise GradesStatistics (Method): Write a program called GradesStatistics, which reads in n grades (of int between 0 and 100, inclusive) and displays the average, minimum, maximum, median and standard deviation. Display the floating-point values upto 2 decimal places. Your output shall look like:Enter the number of students: 4Enter the grade for student 1: 50Enter the grade for student 2: 51Enter the grade for student 3: 56Enter the grade for student 4: 53{50,51,56,53}The average is: 52.50The median is: 52.00The minimum is: 50The maximum is: 56The standard deviation is: 2.29The formula for calculating standard deviation is:Hints:public class GradesStatistics {public static int[] grades; // Declare an int[], to be allocated later.// This array is accessible by all the methods.public static void main(String[] args) {readGrades(); // Read and save the inputs in int[] gradesprintArray(grades);System.out.println("The average is " + average(grades));System.out.println("The median is " +…arrow_forwardPrint "user_num1 is negative." if user_num1 is less than 0. End with newline. Assign user_num2 with 1 if user_num2 is greater than 12. Otherwise, print "user_num2 is less than or equal to 12.". End with newline. My code: user_num1 = int(input())user_num2 = int(input()) if user_num1 < 0: print("user_num1 is negative.") if user_num2 > 12: user_num2 == 1 else: print("user_num2 is less than or equal to 12.") print('user_num2 is', user_num2) When the input is 0 and 13 my output for user_num2 is 13 and it should be 1. I don't know what I'm doing wrong.arrow_forward
- After execution of the following code, what is stored in valueNum?All variables are using data type int. Note that num1=3, num2=5, and num3=7.if (num2> num3)if (num1 > num2)valueNum =num2;elsevalueNum =num3;elseif (num2 > num3)valueNum =num1;elsevalueNum = num3;a. the smallest value of num1, num2, and num3b. the largest value of num1, num2, and num3c. smaller of num1 and num2d. larger of num1 and num3e. randomly selected value from num1, num2, and num3Explain your answer.arrow_forwardWhat is the value stored at x, given the statements? int x; x = 6 / static_cast<int> (4.5 + 6.4);arrow_forwardGiven: int num1, num2, newNum;double x, y;Which of the following assignments are valid? If an assignment is not valid,state the reason.a. num1 = 35;b. newNum = num1 – num2;c. num1 = 5; num2 = 2 + num1; num1 = num2 / 3;d. num1 * num2 = newNum;e. x = 12 * num1 - 15.3;f. num1 * 2 = newNum + num2;g. x / y = x * y;h. num2 = num1 % 2.0;i. newNum = static_cast<int> (x) % 5;j. x = x + y - 5;k. newNum = num1 + static_cast<int> (4.6 / 2);arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education