Answer to Question #266595 in Java | JSP | JSF for Shan

Question #266595

Create a class “StudentName” with a main function. Take a variable of integer data type from user and store its value into variable name “rollno”. Print the name of specific student using switch statements.


Hint: Use 4 different cases and one default. The value of cases should be


Case 10


Case 11


Case 12


Case 13

1
Expert's answer
2021-11-16T00:46:54-0500
import java.util.Scanner;
public class StudentName
{
	public static void main(String[] args) {
	    Scanner input=new Scanner(System.in);
	    System.out.println("Enter an interger: ");
	    int rollno=input.nextInt();
		switch(rollno){
		    case 10:
		        System.out.println("Student's name is Bob");
		        break;
		   case 11:
		        System.out.println("Student's name is Ruth");
		        break;
		   case 12:
		        System.out.println("Student's name is Hassan");
		        break;
		  default:
		        System.out.println("Invalid");
		}
	}
}

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