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)
- Print "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_forwardHow do you fix this?arrow_forwardWhat is the value stored at x, given the statements? int x; x = 6 / static_cast<int> (4.5 + 6.4);arrow_forward
- Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Assign userNum2 with 4 if userNum2 is greater than 9. Otherwise, print "userNum2 is less than or equal to 9.". End with newline. 1 import java.util.Scanner; 2 public class UserNums { public static void main (String [] args) { int userNum1; int userNum2; 4 6. 7 Scanner input userNum1 = 8. = new Scanner(System.in); input.nextInt(); input.nextInt(); 9. 10 userNum2 11 12 V* Your code goes here */ 13 System.out.println("userNum2 is " } 14 + userNum2); 15 16 17 }arrow_forwardAfter Exception of following statements: int x, y; char ch; cin ignore (7, 2'); cin.get(ch): cin ignore(10, '2'); cin>>y; cin ignore(15,'A'); cin>>x; Suppose the input was: 87.5 90 176 23 89 27 A 0.1. The values will be: x=6, y-23 and ch='A' False will be : x=87.5, y=90 , and ch='A' False will be : x=0, y=3 and ch='' True False will be : x=17, y=6 , and ch='A'arrow_forwardI need the solution for these 3 questions in java, please.arrow_forward
- Analyze the following code: int x = 0;int y = ((x < 100) && (x > 0)) ? 1: -1; The code has syntax error. y becomes 1 after the code is executed. y becomes -1 after the code is executed. The code has run time error.arrow_forward6. Which of the below code contains correct overloading code? Why would the other won't work? Code 1 double myMultiply. (int x){ return 10 x; Code 2 int awMultielx (int x){ return 10 x; } double yMultirly. (double x){ double yMultiely (int x){ return 20 x; return 2e * x; 7. What would be the output for the following program and why ( explain in short): Bublis static void nain(String acsal))( String."; String si - "Testing Java Program String s2 - sukstriui13); 8. Write the code in Java for the following class from the UML diagram below: Vehicle -passengers: int -maxSpeed: double -color: String +Vehiclelint,double.String) +setColor(): void +getColor(): String +findCaracityl): double The findCapacityl) method return the capacity of the vehicle by the following formula: Capacity = passengers * 75 L0.20 * maxSpeed)arrow_forwardSummary 2 HouseSign.py - This program calculates prices for cu house signs. In this lab, you complete a prewritten Python program for a carpenter who creates personalized house signs. The program is supposed to compute the price of any sign a customer orders, based 4 on the following facts: 5 # Declare and initialize variables here. 6 # Charge for this sign. • The charge for all signs is a minimum of $35.00. # Number of characters. 8 # Color of characters. • The first five letters or numbers are included in the minimum charge; there is a $4 charge for 9 # Type of wood. 10 each additional character. 11 # Write assignment and if statements here as appropr • If the sign is make of oak, add $20.00. No charge is added for pine. 12 13 # Output Charge for this sign. • Black or white characters are included in the minimum charge; there is an additional $15 14 print("The charge for this sign is $" + str(charge)) charge for gold-leaf lettering. 15 Instructions 1. Make sure the file HouseSign.py…arrow_forward
- What is the printout of the following code? x = 1 def f1(): x=3 print(x) f1() print(x)arrow_forwardWrite a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered: • The number of days spent in the hospital • The daily rate Hospital medication charges • Charges for hospital services (lab tests, etc.) The program should ask for the following data if the patient was an outpatient: • Charges for hospital services (lab tests, etc.) • Hospital medication charges The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the inpatient data, while the other function accepts arguments for outpatient information. Both functions should return the total charges and display it for the user. After the total charges have been calculated and displayed, write the result to a file, PatientReport.txt. You can use the techniques you learned in Chapter…arrow_forwardThe output of the following code snippet is: int main() { char a='P'; printf("Value of a is %c",a); } Select one: a. Value of a is c b. Value of P is c c. Value of P is a d. Value of a is Parrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,