Problem
Write a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below.
Input Format
The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains a character.
Output Format
For each test case, display the Ship Class depending on ID, in a new line.
Constraints
1 ≤ T ≤ 1000
Sample 1:
Input
Output
3
B
c
D
BattleShip
Cruiser
Destroyer
Solution:
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
char ch;
cin>>t;
while(t--)
{
cin>>ch;
if(ch=='B' || ch=='b')
cout<<"BattleShip"<<endl;
if(ch=='C' || ch=='c')
cout<<"Cruiser"<<endl;
if(ch=='D' || ch=='d')
cout<<"Destroyer"<<endl;
if(ch=='F' || ch=='f')
cout<<"Frigate"<<endl;
}
return 0;
}
Comments
Post a Comment