Computer Science, asked by vikasyadav8bcca, 5 months ago

Write a java program that accept your name through keyboard and display a Greeting.

Answers

Answered by aishadey10
1

Answer:

output=

Enter the Name:Sekhar

Hello Sekhar. Welcome!

Explanation:

import java.io.*;

class PrintName{ //Name is the class name which is not main class

void setWish(String nameread){ // Method name is setWish with string parameter

System.out.println("Hello "+nameread+"."+" Welcome!"); // printing the required output

}

}

class PrintString{ // main class name

public static void main(String args[]) throws IOException{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

//reading input stream

PrintName pn=new PrintName(); // creating object for Name class

System.out.print("Enter the Name:");

String nameread=br.readLine(); //nameread string variable takes the input value

pn.setWish(nameread); // calling method setWish with one argument nameread.

}

}

Similar questions