In: Computer Science
Write a program that: a.Asks the user for their first name. b.Asks the user for their age. c.Asks the user for their last name. d.Print out to the user the following information: i.Number of characters in the first & last name combined ii.The full name all in upper case letters iii.The full name all in lower case letters iv.The first letter of the name v.The age Compile and test your code in NetBeans and then on Hackerrank at www.hackerrank.com/csc127-chapter2-classwork then choose CSC127 Chapter 2-2 Scanner and String Classes Submit your .java file and a screenshot of passing all test cases on Hackerrank.
import java.util.Scanner;
public class StudentInfo {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
System.out.println("Enter
firstName: ");
String fname = sc.nextLine();
System.out.println("Enter age:
");
int age = sc.nextInt();
System.out.println("Enter lastName:
");
String lname = sc.nextLine();
lname = sc.nextLine();
//adding fname and lname to make
full name
String name = fname + lname;
//printing number of chars in full
name
System.out.println("Total Number of
chars in name: " + name.length());
//printing name in uppercase
System.out.println("Name (Upper): "
+ name.toUpperCase());
//printing in lower case
System.out.println("Name (lower): "
+ name.toLowerCase());
//printing first char using
charAt()
System.out.println("First letter: "
+ name.charAt(0));
System.out.println("Age: " +
age);
}
}