Answer to Question #251756 in Java | JSP | JSF for guru

Question #251756

Your task is to then create a java program that when given an acronym with its meaning plus some sentence, the program replaces the first occurrence of the acronym in the sentence with its meaning.

 Sample run 1: 

Enter an acronym and its meaning (separated by spaces): NUST Namibia University of Science and Technology                               

Enter a sentence: Welcome to my NUST.                                                            Output: Welcome to my Namibia University of Science and Technology.

1
Expert's answer
2021-10-17T01:45:33-0400

Source code

import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String s;
		System.out.print("Enter a sentence: ");
		s=in.nextLine();
		String s2="Namibia University of Science and Technology";
		String s3=s.replace("NUST",s2);
		System.out.println(s3);
	}
}

Output


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS