Evans High School
IT 407
Using Objects Coding Practice Write the code to print a random number from 1 to 100. You can use Math.random() to get a value between 0 and not quite 1. public class Test1 { public static void main(String[] args) { int num = Math.random() * 100; System.out.println(num); } } The following code should get the first letter of the first name,
...[Show More]
Using Objects Coding Practice Write the code to print a random number from 1 to 100. You can use Math.random() to get a value between 0 and not quite 1. public class Test1 { public static void main(String[] args) { int num = Math.random() * 100; System.out.println(num); } } The following code should get the first letter of the first name, middle name, and last name and append (concatenate) them together and then return them all in lowercase. However, the code has errors. Fix the code so that it compiles and runs correctly. public class Test1 { public static void main(String[] args) { String firstName = "Sofia”; String middleName = "Maria"; String lastName = "Hernandez"; String initials = firstName.substring(0,1) “” + middleName.substring(0,1) “” + lastName.substring(0,1); System.out.println(initials.toLowerCase());
[Show Less]