Question

can someone help me with this program ? first name : Tom Last name : Damerji...

can someone help me with this program ?

first name : Tom

Last name : Damerji

Mother's maiden name : White

Town i was born in : Beirut

Write a new method that determines your Star Wars name.

The method will have 4 parameters, your first name, last name, mothers maiden name, and the town you were born. (1 point)

The method will return one String object, your Star Wars name.  (1 point)

Your Star Wars name is created as per the instructions in blue below:   (2 point)

Your Star Wars First Name:
1. Take the first 3 letters of your last name.
2. Add to that, the first 2 letters of your first name.

Your Star Wars Last Name:
1. Take the first 2 letters of your mother's maiden name.
2. Add the first 3 letters of the name of the town in which you were born.

In the main method:

Ask the user to enter their first name, last name, mothers maiden name, and town they were born. Store all this data as different Strings. (1 point)

Pass all this data to your method, and the method should generate and return the users Star Wars name. (1 point)

Get the return value of the method, and display it to the screen.  (1 point)

Hint: See the SubstringDemo.java file in the Examples section for how to parse a String

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//****Code************

import java.util.Scanner;

public class StarWarsName {

//method to determine star wars name

public static String getStarWarsName(String fname, String lname, String mmName, String tbIn)

{

//declare variabels

String starWarsName ="";

String starWarsFirstName;

String starWarsLastName;

//str wars first name

starWarsFirstName = lname.substring(0,3) + fname.substring(0,2).toLowerCase();

//star wars last name

starWarsLastName = mmName.substring(0,2)+ tbIn.substring(0, 3).toLowerCase();

//star wars name

starWarsName = starWarsFirstName+" "+ starWarsLastName;

return starWarsName;

}

public static void main(String [] args)

{

//read input

Scanner scanner = new Scanner(System.in);

System.out.print("First name : ");

String firstName = scanner.nextLine();

System.out.print("Last name : ");

String lastName = scanner.nextLine();

System.out.print("Mother's maiden name : ");

String mothersMadainName = scanner.nextLine();

System.out.print("Town i was born in : ");

String townBornIn = scanner.nextLine();

//call function to get star wars name

String starWarsName = getStarWarsName(firstName, lastName, mothersMadainName, townBornIn);

System.out.println("\n\nYour Star Wars name is: "+ starWarsName);

}

}

//************Output Screenshot****

//****Please do let me know if you have any doubts or want me to modify the code************

Add a comment
Know the answer?
Add Answer to:
can someone help me with this program ? first name : Tom Last name : Damerji...
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
  • Document2 Tell me Layout References Mailings Review View 1. Write a program named Lab17B that will...

    Document2 Tell me Layout References Mailings Review View 1. Write a program named Lab17B that will read 2 strings and compare them. a. Create a bool function named compareLetters that will accept 2 string variables as parameters and will return true if the strings have the same first letters and the same last letters. It will return a false otherwise. b. Create a bool function named inside that will accept the 2 string variables in the order they were entered)...

  • Complete the generateFormalName method so that… you return the formal name (Mr. or Ms. + last...

    Complete the generateFormalName method so that… you return the formal name (Mr. or Ms. + last name) given a full name and gender (Strings) as parameters. --You can assume a valid name & gender (any case allowed) is passed in. Example 1: ("Bob Smith", "MaLE") passed in should generate "Mr. Smith" Example 2: ("Maggie May", "feMALE") passed in should generate "Ms. May" Tip 1: You are given a String formalName initialized to the empty String -- you will want to...

  • Can someone verify the programming code below for visual studio code python. Stores your first name...

    Can someone verify the programming code below for visual studio code python. Stores your first name as a variable. Use all lowercase letters when you declare it. Stores your last name as a variable. Use all uppercase letters when you declare it. Prints out, "Hello, <first name> <last name>" with the first name converted to uppercase letters and the last name converted to lowercase letters using string functions. Prints out two newlines. Prints out the following: "Start by doing what's...

  • JAVA Can you make this return the first letter of  first and last name capitalized? import java.io.File;...

    JAVA Can you make this return the first letter of  first and last name capitalized? import java.io.File; import java.io.IOException; import java.util.*; public class M1 {    public static void main(String[] args) {        //scanner input from user    Scanner scanner = new Scanner(System.in); // System.out.print("Please enter your full name: "); String fullname = scanner.nextLine(); //creating a for loop to call first and last name separately int i,k=0; String first="",last=""; for(i=0;i<fullname.length();i++) { char j=fullname.charAt(i); if(j==' ') { k=i; break; } first=first+j;...

  • use Java and it must work for any name String Manipulator Write a program to manipulate...

    use Java and it must work for any name String Manipulator Write a program to manipulate Strings. Store your full name into one String variable. It must include first name, middle name, last name, cach separated by spaces. Spaces could vary. If you do not have a middle name make up one For example the string to be processed could be any of the following John Plain Doe John Plain Doc John Plain Doe Your program must be able to...

  • Create a class called Student. This class will hold the first name, last name, and test...

    Create a class called Student. This class will hold the first name, last name, and test grades for a student. Use separate files to create the class (.h and .cpp) Private Variables Two strings for the first and last name A float pointer to hold the starting address for an array of grades An integer for the number of grades Constructor This is to be a default constructor It takes as input the first and last name, and the number...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • Write a statement that creates a RegExp object that remembers the first and last name, but...

    Write a statement that creates a RegExp object that remembers the first and last name, but does not remember the title. Using the RegExp object's exec() method, assign the result variable with the remembered first and last name of the string userName. var userName = "Dr. Greg House"; // Code will also be tested with "Mr. Howard Wolowitz" /* Your solution goes here */ console.log(result[1] + " " + result[2]);

  • 1. Write a program to input a list of names (strings) from the user and store...

    1. Write a program to input a list of names (strings) from the user and store them in an ArrayList. The input can be terminated by entering the empty string or by entering the string “quit”. 2. Add further functionality to your program so that it searches the ArrayList to find the first string and the last string according to dictionary ordering and then prints out these strings (names). Do this exercise without sorting the names in the ArrayList. For...

  • Java, can you help me out thanks. CSCI 2120 Introduction For this assignment you will implement...

    Java, can you help me out thanks. CSCI 2120 Introduction For this assignment you will implement two recursive methods and write JUnit tests for each one. You may write all three methods in the same class file. You are required to write Javadoc-style documentation for all of your methods, including the test methods. Procedure 1) Write method!! a recursive method to compare two Strings using alphabetical order as the natural order (case insensitive, DO NOT use the String class built-in...

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