Ask Question
24 April, 21:18

Write a switch statement that checks origLetter. If origLetter is 'a' or 'A', assign greekLetter with 'Alpha'. If origLetter is 'b' or 'B', assign greekLetter with 'Beta'. For any other character, assign greekLetter with 'Unknown'.

function greekLetter = ConvertAlphabet (origLetter)

% Complete the switch statement to assign greekSymbol with 'Alpha',

% 'Beta', or 'Unknown' based on origLetter

switch (origLetter)

case 'a'

greekLetter = 'Alpha';

otherwise

greekLetter = 'Unknown';

end

end

+5
Answers (1)
  1. 24 April, 22:14
    0
    import java. util. Scanner;

    public class num6 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter an alphabet");

    char origLetter = in. next (). charAt (0);

    String greekLeter = "";

    switch (origLetter) {

    case 'A':

    greekLeter="Alpha";

    break;

    case 'a':

    greekLeter="Alpha";

    break;

    case 'B':

    greekLeter = "Beta";

    break;

    case 'b':

    greekLeter = "Beta";

    default:

    greekLeter="Unknown";

    }

    System. out. println ("You entered the letter "+origLetter+" The greek letter is" +

    " "+greekLeter);

    }

    }

    Explanation:

    A complete Java program is given above Using a the Scanner class, the user is prompted for a character which is received and stored in the variable origLetter The switch statement implements four cases, case of A, a, B and b to handle lower and upper case characters and assigns the appropriate String to the variable greekLeter as specified by the question Finally the letter entered and the greekLeter is printed out.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a switch statement that checks origLetter. If origLetter is 'a' or 'A', assign greekLetter with 'Alpha'. If origLetter is 'b' or 'B', ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers