Respuesta :
Answer:
Here is the JAVA program:
class Main { //class name
public static void main(String[] args) { //start of main method
int status = 200; //sets status to 200
switch( status ){ //switch statement
case 200: //if code is 200
System.out.println("OK (fulfilled)"); //displays OK (fulfilled) if case is 200
break;
case 403: //if code is 403
System.out.println("forbidden"); //displays forbidden if case is 403
break;
case 404: //if code is 404
System.out.println("not found"); //displays not found if case is 404
break;
case 500: //if code is 500
System.out.println("server error"); //displays server error if case is 500
break;
default: //if status is set to code other than above codes
System.out.println("Unknown code"); //displays Unknown code
break; } } }
Explanation:
If you want to take the status code as input from user then use the following statements:
int status;
Scanner input = new Scanner(System.in);
System.out.print("Enter status code: ");
status= input.nextInt();
After this you can add the switch code chunk in the Answers section. Also import the Scanner class to take status code as input from user:
import java.util.Scanner;
The screenshot of the program along with its output is attached.
