2.Write only the select case statements for

the following problem statement.
The marital code of a person is stored in
the variable called marCode. Display the
corresponding description on the screen.
Provide for an incorrect marital code
Marital Code
S Single
D Divorced
M Married
W Widowed
I Incorrect

print

select code {
S: Single
D: Divorced
M: Married
W: Widowed
else: Incorrect
};

use syntax appropriate for your programming language.

if marital s=s then

Select case marCode

case “S”
display “Single”
case “D”
display “Divorced”
case “M”
display “Married”
case “W”
display “Widowed”
case else
display ”Incorrect”
endselect

To write the select case statements to display the corresponding description based on the marital code, you can follow these steps:

1. Start by declaring the variable `marCode` to store the marital code.
2. Use a select case statement to check the value of `marCode` and provide the corresponding description based on the code.
3. Add cases for each possible value of `marCode` (S, D, M, W, and I).
4. For each case, display the corresponding description on the screen.
5. Provide a case for an incorrect marital code to display the description "Incorrect" if none of the other cases match.

Here's an example of how to write the select case statements in a programming language like Visual Basic:

```vb
Dim marCode As String = "M"

Select Case marCode
Case "S"
Console.WriteLine("Single")
Case "D"
Console.WriteLine("Divorced")
Case "M"
Console.WriteLine("Married")
Case "W"
Console.WriteLine("Widowed")
Case "I"
Console.WriteLine("Incorrect")
Case Else
Console.WriteLine("Invalid marital code")
End Select
```

In this example, the variable `marCode` is set to "M" (for Married). The select case statement checks the value of `marCode` and displays the corresponding description "Married" on the screen.

If `marCode` is set to a value other than S, D, M, W, or I, the case Else is used to display the message "Invalid marital code" indicating that the code entered is not recognized.

You can modify the value of `marCode` to test different cases and see the corresponding descriptions displayed on the screen.