Question: Type CastGiven the String called myString initialized to a String, do the following: Declare an Integer variable named convertToNum Store the value of type casting

Type CastGiven the String called myString initialized to a String, do the following:
Declare an Integer variable named convertToNum
Store the value of type casting myString to an Integer in convertToNum
Print convertToNum to the console.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class TypeChange {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String myString = in.nextLine();
/***** DO NOT CHANGE THE CODE ABOVE THIS LINE *****/
// WRITE YOUR CODE HERE
/***** DO NOT CHANGE THE CODE BELOW THIS LINE *****/
System.out.println("The string "+ myString +" has been converted to "+ convertToNum +" an Integer!");
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!