Question

In: Computer Science

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 and test your code in NetBeans and then on Hackerrank and screenshot of passing all test cases on Hackerrank.

Solutions

Expert Solution

Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Also, sharing all the screenshots of a sample run.


Thank You !!

===========================================================================

import javax.swing.*;

public class Name{


    public static void main(String[] args) {

        String firstName = JOptionPane.showInputDialog("Enter first name: ");
        String age = JOptionPane.showInputDialog("Enter your age: ");
        String lastName = JOptionPane.showInputDialog("Enter last name: ");

        //  i. Number of characters in the first & last name combined
        int totalCharacters = firstName.length() + lastName.length();
        JOptionPane.showMessageDialog(null, "Total characters: " + totalCharacters);
        //ii. The full name all-in upper-case letters
        String fullNameInU = firstName.toUpperCase() + " " + lastName.toUpperCase();
        JOptionPane.showMessageDialog(null, fullNameInU);
        //iii. The full name all-in lower-case letters
        String fullNameInL = firstName.toLowerCase() + " " + lastName.toLowerCase();
        JOptionPane.showMessageDialog(null, fullNameInL);
        // iv. The first letter of the name
        JOptionPane.showMessageDialog(null, "First letter: " + firstName.charAt(0));
        //The age
        JOptionPane.showMessageDialog(null, "Your age: " + age);


    }
}


Related Solutions

Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
Tail of a File, C++ Program. write a program that asks the user for the name...
Tail of a File, C++ Program. write a program that asks the user for the name of a text file. The program should display the last 10 lines, or all lines if less than 10. The program should do this using seekg Here is what I have so far. #include<iostream> #include<fstream> #include<string> using namespace std; class File { private:    fstream file;    string name; public:    int countlines();    void printlines(); }; int File::countlines() {    int total =...
Write a program that asks the user for a file name. The file contains a series...
Write a program that asks the user for a file name. The file contains a series of scores(integers), each written on a separate line. The program should read the contents of the file into an array and then display the following content: 1) The scores in rows of 10 scores and in sorted in descending order. 2) The lowest score in the array 3) The highest score in the array 4) The total number of scores in the array 5)...
In.java Write down a program that asks the user for their full name given in the...
In.java Write down a program that asks the user for their full name given in the format first last. The program will do the necessary processing and print the name in a table with 3 columns: Last, First, Initials. Requirements/Specifications... Your program run must be identical with the one shown as an example (both in how it reads the input and it on what it prints). The table must have the top and bottom lines as shown. The columns for...
Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
Write a program that asks the user for a Fahrenheit temperature and calls a function name...
Write a program that asks the user for a Fahrenheit temperature and calls a function name Celsius that returns the temperature in Celsius of the Fahrenheit temperature sent to it. Your function will look similar to this: double celsius(double f) { double c; : : return c; }
The question asks to allow the user to integer ranging from 1 to 999 using JOPtionpane...
The question asks to allow the user to integer ranging from 1 to 999 using JOPtionpane in JAVA; and display those integers in words. For example, if the user enters 13 the program should display " Thirteen" and loop to ask the user to enter another integers. If the user enters 0, the program should quit. If the user enters an integer greater than 999, the program should display an error message and ask the user to enter an integer...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT