JAVA program to accomplish task using string/string Buffer class

Write a program to Implement a program to accomplish the following task using string/string Buffer class:
i. Accept a password from the user.
ii. Check if password is correct then display “Good”
Else display “Incorrect password”
iii. Append the password with the string “Welcome to Java!!!”
iv. Display the password in reverse order.
v. Replace the character ‘!’ in password with “*” character.

import java.lang.*;
class q6String
	public static void main(String args[]) throws IOException
		BufferedReader br = new BufferedReader(new InputStreamReader(;
		String s1 = "!!sspp!!";
		String s2;
		System.out.println ("Enter Password");
		s2 = br.readLine();
			System.out.println ("Good");
			System.out.println ("Password is incorrect");
		String s3 = "Welcome to Java!!!";
		StringBuffer sb = new StringBuffer(s1);
		System.out.println ("Appended Password = "+sb);
		StringBuffer s4 = new StringBuffer(s1);
		System.out.println ("String in Reverse Order = "+s4);
		System.out.println ("Replaced '!' with '*' = "+s1.replace('!','*'));	


Rabins Sharma Lamichhane

Rabins Sharma Lamichhane is senior ICT professional who talks about #it, #cloud, #servers, #software, and #innovation. Rabins is also the first initiator of Digital Nepal. Facebook: rabinsxp Instagram: rabinsxp

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *