68.9k views
2 votes
Write a switch statement that checks origLetter. If 'a' or 'A', print 'Alpha'. If 'b' or 'B', print "Beta'. For any other character, print 'Unknown". Use fall-through as appropriate. End with newline.

User Papa Sax
by
7.3k points

2 Answers

7 votes

You haven't specified the programming language so I am going to assume you need to do this in C++.

#include <iostream>

int main(int argc, int* argv[])

{

char origLetter;

std::cin >> origLetter;

switch (origLetter)

{

case 'a':

case 'A':

std::cout << "Alpha"; break;

case 'b':

case 'B':

std::cout << "Beta"; break;

default:

std::cout << "Unknown";

}

std::cout << std::endl;

}

Hope this helps.

User Satadru Biswas
by
7.6k points
4 votes

Answer:

String greekLeter ="";

switch (origLetter) {

case 'A':

case 'a':

greekLeter = "Alpha";

System.out.println("Alpha");

break;

case 'B':

case 'b':

greekLeter= "Beta";

System.out.println("Beta");

break;

default:

greekLeter="Unknown";

System.out.println("Unknown");

break;

}

Step-by-step explanation:

Write a switch statement that checks origLetter. If 'a' or 'A', print 'Alpha'. If-example-1
User Burndog
by
7.1k points