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...

  • 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...

  • 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...

  • C++ (1) Write a program to prompt the user for an input and output file name....

    C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...

  • Write a complete java program that prompts the user for their name and two numbers. The...

    Write a complete java program that prompts the user for their name and two numbers. The correct java methods and parameters must be passed to find the length of the name entered and return “TRUE” if the sum of numbers is even, or FALSE if the sum of numbers is odd: Notes included in the program Sample Program Please enter a name and I will tell you the length of the name entered John Then length of the name John...

  • #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a...

    #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and...

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
ADVERTISEMENT