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 the owner of RabinsXP who is constantly working for increasing the Internet of Things (IoT) in Nepal. He also builds android apps and crafts beautiful websites. He is also working with various social services. The main aim of Lamichhane is to digitally empower the citizens of Nepal and make the world spiritually sound better both in terms of technology and personal development. Rabins is also the first initiator of Digital Nepal.

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button