Question

Need Psuedo-code and java program code (not python) for following problem: (Please make the psuedo-code as...

Need Psuedo-code and java program code (not python) for following problem: (Please make the psuedo-code as simple as possible to understand)

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:

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 prompt which is a String parameter passed to the function. You must use correct and consistent indentation and alignment, meaningful variable names, named constants, descriptive comments, and an ID header.

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

Psuedo-code:

  1. Import Scanner class which helps to read input from user.
  2. Declare string variables firstname and lastname.
  3. Declare the object with any name(name in this program) and initialize with predefined standard input object.
  4. Prompt the user saying please enter your firstname and lastname.
  5. Take the string inputs using character input.
  6. Then concatenate both names and adding "Hello" to the first "!" to the last.
  7. Then print output

Working code and Comments for better understanding:

import java.util.Scanner; //Import using Scanner class to read user input
class Main{

public static void main(String args[]){
function();
}

private static void function(){

String firstname, lastname; //Declare string variables

//Declare the object with any name(name in this program) and initialize with predefined standard input object.

Scanner name = new Scanner(System.in);

System.out.println("Please enter your first name:"); //Prompt user asking for first name

firstname = name.nextLine(); // String input firstname

System.out.println("Please enter your last name:"); //Prompt user asking for last name

lastname = name.nextLine(); // String input of lastname

String s="Hello, "+firstname+" "+lastname+"!"; // concatenate both names and adding "Hello" to the first "!" to the last.

System.out.println(s); //Printing output of string s

}
}

Code Screenshots:

Output Screenshots:

Hope this helps, if you like my answer, give it a thumbs up.

Add a comment
Know the answer?
Add Answer to:
Need Psuedo-code and java program code (not python) for following problem: (Please make the psuedo-code as...
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
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