62 540
Assignments Done
98,7%
Successfully Done
In June 2018

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).
Expert's answer
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions