Question

Write a program call FancyMyName which as the user for their first and last name and...

Write a program call FancyMyName which as the user for their first and last name and print it like the example output bellow:

Please enter your first name and last name, separated by a space?

You entered the name: Louis Henry

Output: LoUiS HeNrY

(Code needed in Java)

Thank You.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//Main.java
import java.util.Scanner;
public class FancyMyName  {
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    System.out.print("Enter name: ");
    String s = scanner.nextLine();

    System.out.println("You entered the name: "+s);
    String res = "";
    char ch;
    for(int i = 0;i<s.length();i++){
      ch = s.charAt(i);
      if(i%2==0){
        res += s.substring(i,i+1).toUpperCase();
      }
      else{
        res += s.substring(i,i+1).toLowerCase();
      }
    }
    System.out.println("Output: "+res);
  }
}

Add a comment
Know the answer?
Add Answer to:
Write a program call FancyMyName which as the user for their first and last name and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to enter a list of names. Each person's name...

    Write a program that prompts the user to enter a list of names. Each person's name is separated from the next by a semi-colon and a space (: and the names are entered lastName, firstName (i.e. separated by ',). Your program should then print out the names, one per line, with the first names first followed by the last names. A sample run of your program should look like Please enter your list of names: Epstein, Susan; St. John, Katherine;...

  • Design a modular program using pseudo-code which prompts a user for their first name, followed by...

    Design a modular program using pseudo-code which prompts a user for their first name, followed by their last name; then displays a "Hello" salutation which concatenates their first name with their last name. Sample output (user input shown in red): Please enter your first name: John Please enter your last name: Smith Hello, John Smith! Your program must include a main module and one function; this function prompts the user for either their first name or last name, using a...

  • (Obtaining Substrings) Write a program that prompts the user to enter full name contains the first...

    (Obtaining Substrings) Write a program that prompts the user to enter full name contains the first name, middle name and last name separated by a space and extract the first name, middle name and last name from the input string. Here is a sample run: Enter the name: Dennis MacAlistair Ritchie First Name: Dennis Middle Name: MacAlistair Last Name: Ritchie JAVA

  • JAVA Write a program which will receive three pieces of data from the user: two floating...

    JAVA Write a program which will receive three pieces of data from the user: two floating point numbers, and a single character +, -, *, or /. Perform input validation on the character. Your code then will send these three pieces of data to a method which will calculate and output the results based on the user's entries. For example, if the user entered: "12.1, 23.2, +" the output would be "12.1 + 23.2 = 35.3." STRONG HINT: in a...

  • Write a program that separately prompts the user for a first name and last name and...

    Write a program that separately prompts the user for a first name and last name and outputs a string containing the following information, in order: a. First letter of the user's name. b. First five letters of the user's last name. c. A random two-digit integer You must construct the desired string ensuring all characters are lowercase; output the identification string accordingly. Assume the last name contains at least 5 characters. You must use the Random (java.util.Random) class to generate...

  • (Java) HELP! Create a program that will ask the user to enter their first name and...

    (Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...

  • Using python, write a program that lets the user enter this information: First name & Last...

    Using python, write a program that lets the user enter this information: First name & Last name weight age gender height systolic & diastolic blood pressure body temperature in Fahrenheit After the information has been entered, the results should be printed on the display based on the information below -BMI -Temp Conversion -Mean blood pressure -weight conversion (lbs to kg) -height conversion (inches to cm) The output should look like: First Name Last name is ___ cm and ____kgs. First...

  • Write a program that reads a person's first and last names, separated by a space. Then...

    Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is Maya Jones Tones, Maya import java . util·Scanner; public class SpaceReplace 4 public static void main (String [1 ares) f( Scanner scnr-new Scanner(System.in); String firstName; String lastName; Your solution goes here */ 10 12

  • read the code and comments, and fix the program by INSERTING the missing code in Java...

    read the code and comments, and fix the program by INSERTING the missing code in Java THank you please import java.util.Scanner; public class ExtractNames { // Extract (and print to standard output) the first and last names in "Last, First" (read from standard input). public static void main(String[] args) { // Set up a Scanner object for reading input from the user (keyboard). Scanner scan = new Scanner (System.in); // Read a full name from the user as "Last, First"....

  • Name : StarryArrays Write a program called StarryArrays which prompts user for the number of items...

    Name : StarryArrays Write a program called StarryArrays which prompts user for the number of items in an array (a non-nega- tive integer), and saves it in an int variable called numltems. It then prompts user for the values of all the items (non-negative integers) and saves them in an int array called items. The program shall then print the contents of the array in a graphical form, with the array index and values represented by number of stars For...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT