Answer to Question #323581 in Java | JSP | JSF for Harfa

Question #323581

Write a program that reads a web address (for instance, www.yahoo.com) from the keyboard and outputs whether this web address is for a government, a university, a business, a non-profit organization, or another entity.

●      If the web address ends with gov, it is a government web address.

●      If the web address ends with edu, it is a university web address.

●      If the web address ends with com, it is a business web address.

●      If the web address ends with org, it is a non-profit organization’s web address.

Otherwise, it is a web address for another entity



1
Expert's answer
2022-04-04T19:56:01-0400
import java.util.Scanner;

public class Www {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.print("Enter a web address (for instance, www.yahoo.com): ");
        String web=scan.nextLine();
        if(web.contains("gov")){
            System.out.println("It is a government web address.");
        }
        else if(web.contains("edu")){
            System.out.println("It is a university web address.");
        }
        else if(web.contains("com")){
            System.out.println("It is a business web address.");
        }
        else if(web.contains("org")){
            System.out.println("It is a non-profit organization’s web address.");
        }
        else {
            System.out.println("It is a web address for another entity.");
        }
    }
}

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