# Id and Ship Codechef Solution

#### ByBrokenprogrammers

Dec 6, 2022

Hello Programmers In this post, you will know how to solve the Id and Ship Codechef Solution.

One more thing to add, donâ€™t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.

### Problem

Write a program that takes in a letter class ID of a ship and display the equivalent string class description of the given ID. Use the table below.

Class ID Ship Class

B or b BattleShip

C or c Cruiser

D or d Destroyer

F or f Frigate

### Input

The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains a character.

### Output

For each test case, display the Ship Class depending on ID, in a new line.

### Constraints

• 1 <= T <= 1000

### Example

Input:

```3
B
c
D
```

Output:

```BattleShip
Cruiser
Destroyer```

### Id and Ship CodeChef Solutions in Python

```T = int(input())
for i in range(T):
n = input()
if (n =="B" or n == "b"):
print("BattleShip")
elif (n == "C" or n == "c"):
print("Cruiser")
elif (n == "D" or n == "d"):
print("Destroyer")
else:
print("Frigate")```

### Id and Ship CodeChef Solutions in CPP

```#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace::std;
int main(int argc, const char * argv[]) {
int t;
cin >> t;
while (t--) {
char n;
cin >> n;
n = toupper(n);
switch (n) {
case 'B':
cout << "BattleShip" << endl;
break;
case 'C':
cout << "Cruiser" << endl;
break;
case 'D':
cout << "Destroyer" << endl;
break;
default:
cout << "Frigate" << endl;
break;
}
}
return 0;
}```

### Id and Ship CodeChef Solutions in JAVA

```import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
int t=input.nextInt();
char ch;
while(t-->0)
{
ch=input.next().charAt(0);
if(ch=='B' || ch=='b')
System.out.println("BattleShip");
else if(ch=='C' || ch=='c')
System.out.println("Cruiser");
else if (ch=='D' || ch=='d')
System.out.println("Destroyer");
else if(ch=='F' || ch=='f')
System.out.println("Frigate");
}
}
}```

Disclaimer: The above Problem (Id and Ship) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.