Answer to Question #240479 in Java | JSP | JSF for Selma Shigwedha

Question #240479
Your task is to then create
a java program that when give a sentence will replace the first occurrence of NUST with Namibia
University of Science and Technology.
Sample run 1:
Enter a sentence: Welcome to my NUST.
Output: Welcome to my Namibia University of Science and Technology.
Sample run 2:
Enter a sentence: The nust is a great institution of high learning.
Output: The Namibia University of Science and Technology is a great institution of high learning.
1
Expert's answer
2021-09-22T23:44:03-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner in=new Scanner(System.in);
		String orginal_str=in.nextLine();  
		String r_str="Namibia University of Science and Technology";
        String s=orginal_str.replace("NUST",r_str); 
        System.out.println(s); 
	}
}

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
New on Blog
APPROVED BY CLIENTS