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

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 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.
Write a Python program that asks the user to enter a student's name and 8 numeric...
Write a Python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student determine_grade -...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT