Computer Science, asked by dishapai2277, 13 hours ago

Write java program(info java)to print your name and location.

Answers

Answered by shrutipatil555
1

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