Answer to Question #26341 in Java | JSP | JSF for hana

Question #26341
Write a program that determines the class of the ship depending on it's class id(identifiers).
1
Expert's answer
2013-03-15T09:54:17-0400
import java.util.Scanner;
public class App {
publicstatic void main(String[] args) {
System.out.print("Entership class id: ");
Scannerscanner = new Scanner(System.in);
Stringinput = scanner.next().toLowerCase();
charclassId = input.charAt(0);

switch(classId) {
case'b':
System.out.println("Battleship");
break;
case'c':
System.out.println("Cruiser");
break;
case'd':
System.out.println("Destroyer");
break;
case'f':
System.out.println("Fregate");
break;
default:
System.out.println("Unknownclass of the ship");
}
}
}

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