Question

In: Computer Science

Write a program that: a.Asks the user for their first name.b.Asks the user for their...

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.

Solutions

Expert Solution

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);

   }
}


Related Solutions

Write a program that prompts the user for their first and lastname. Display the first...
Write a program that prompts the user for their first and last name. Display the first initial of their first name and their last name to the user.Ask the user to input a phone number.The program checks which part of Colorado a phone number is from using the values below.If the second digit of the phone number is one of the below digits, print the phone number and which part of Colorado it is from. If none of the digits...
Write a MIPS assembly program that prompts the user first for a string, then for a...
Write a MIPS assembly program that prompts the user first for a string, then for a character. The program should then search the string for the character and print out the number of times the character appears in the string. You can use as many restrictions as you want, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
Write a program that: a. Asks the user for their first name using a JOptionPane. b....
Write a program that: a. Asks the user for their first name using a JOptionPane. b. Asks the user for their age using a JOptionPane. C. Asks the user for their last name using a JOptionPane. d. Pops up a dialog with 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...
Write a program in Java that first asks the user to type in today's price of...
Write a program in Java that first asks the user to type in today's price of one dollar in Japanese yen, then reads U.S. dollar values and converts each to yen. Use 0 as a sentinel to denote the end of dollar input. THEN the program reads a sequence of yen amounts and converts them to dollars. The second sequence is terminated by another zero value.
Question 1: Write a program to receive a string from the user and compares the first...
Question 1: Write a program to receive a string from the user and compares the first and second half of the word and prints “First and Second Half Same” or “First and Second Half Different”. If the length of the word is odd, ignore the middle letter. For example: Run 1: Enter a word: abcdabc First and Second Half Same Run 2: Enter a word: abcde First and Second Half Different Hint: use the Math.floor() and length() to get the...
Write a Java program that will first ask the user how many grades they want to...
Write a Java program that will first ask the user how many grades they want to enter. Then use a do…while loop to populate an array of that size with grades entered by the user. Then sort the array. In a for loop read through that array, display the grades and total the grades. After the loop, calculate the average of those grades and display that average. Specifications Prompt the user for the number of grades they would like to...
You have been asked to write program that allows the user to input a first name,...
You have been asked to write program that allows the user to input a first name, middle initial (without the period), and last name of a user and then display that person’s name with the first, middle initial followed by a period, and last name last. BEFORE creating the program, use structured programming principles to document how you are going to develop the program. Use Microsoft Word to complete this part of the assessment. Answer each of the following areas:...
Write a java simple document retrieval program that first asks the user to enter a single...
Write a java simple document retrieval program that first asks the user to enter a single term query, then goes through two docuements named doc1.txt and doc2.txt (provided with assignment7) to find which document is more relevant by calculating the frequency of the query term in each document. Output the conclusion to a file named asmnt7output.txt in the following format (as an example for query “java” and “problem”). The percentages in parenthese are respective supporting frequencies. java: doc1(6.37%) is more...
jgrasp environment, java write a complete program that prompts the user to enter their first name,...
jgrasp environment, java write a complete program that prompts the user to enter their first name, middle name, and last name (separately). print out thier name and initials, exactly as shown: your name is: John Paul Chavez your initials are: J. P. C. use string method chartAt() to extract the first (zero-th) character from a name(the name is a string type): username.charAt(0). thank you.
Write a Java program to do the following: Ask the user to enter 10 first names...
Write a Java program to do the following: Ask the user to enter 10 first names (one word - no hyphen or apostrophe) using the keyboard. 1) Display the list of names one per line on the Console. 2) Display the names again, after eliminating duplicates using a HashSet (Your code MUST use HashSet).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT