Question: Add the Correct Data Types! Modify the given variables ( age , pi , isStudent, grade, state ) by assigning appropriate data types. import java.io

Add the Correct Data Types!
Modify the given variables (age, pi, isStudent, grade, state) by assigning appropriate data types.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class CodingQuestion {
public static void main(String[] args){
// Modify code below with the appropriate datatypes:
age =21;
pi =3.14;
isStudent = true;
grade ='A';
state = "California";
/*****DO NOT CHANGE THE CODE BELOW THIS LINE*****/
checkType(age);
checkType(pi);
checkType(isStudent);
checkType(grade);
checkType(state);
}
static void checkType(Object o){
if (o instanceof String){
System.out.println("String");
} else if (o instanceof Integer){
System.out.println("int");
} else if (o instanceof Double){
System.out.println("double");
} else if (o instanceof Character){
System.out.println("char");
} else if (o instanceof Boolean){
System.out.println("boolean");
}
}
}

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!