HTTP is the protocol that governs communications between web servers and web clients (i.e. browsers). Part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. Some of the codes and their meanings are listed below:
200, OK (fulfilled) 403, forbidden 404, not found 500, server error
Given an int variable status, write a switch statement that prints out, on a line by itself, the appropriate label from the above list based on status.
This is what I have for my code but it's still not working and I am unsure as to why.
switch ( status ){
case 200: System.out.println("OK(fulfilled)");
break;
case 403: System.out.println("forbidden");
break;
case 404: System.out.println("not found");
break;
case 500: System.out.println("server error");
break;}
The error I get is "The value of _stdout is incorrect."
32 Answers
Would you be able to post your entire source code? Have you tried using the default case as shown below?
public void run() { //enter a test case here to see if your console prints the output: int status = readInt("Enter case here: "); switch ( status ){ case 200: System.out.println("OK(fulfilled)"); break; case 403: System.out.println("forbidden"); break; case 404: System.out.println("not found"); break; case 500: System.out.println("server error"); break;
//Try the default case here: default: break; }
}
} 0 I had the same problem and figured out you're supposed to use System.out.print(""), because it's supposed to be entered on a line by itself.