Starting from:

$15

C++ program that uses a switch statement to print out the scale mnemonic

1. In your Lab-3 directory, make a new file called ex2. cpp. In this file, build a C++ program that uses a switch statement to print out the scale mnemonic corresponding to a musical note that is input by the user. The valid musical notes are A, B, C, D, E, F, and G.

The user will enter a given musical note by pressing the key (e.g., 'A') on the computer keyboard corresponding to that note. The scale mnemonic for a musical note is just an easy-to-remember word that is associated with the note. Musicians often use scale mnemonics when practicing vocals. If you have ever seen the movie "The Sound of Music"

you have heard scale mnemonics being used. The scale mnemonics for musical notes are:

Note I Scale Mnemonic

--------+-----------------------

C |

Your program should accept uppercase or lowercase characters for musical notes that are input by the user. For instance, the 'F' or 'f' keyboard keys should both represent the valid musical note F. If the user inputs a character corresponding to a valid musical note, your program should output the scale mnemonic for that note. The scale mnemonic should just be a string constant (e.g., "fa"). If the user inputs a character that does not correspond to a valid musical note, your program should emit a message of the form "Invalid note entered" and stop. You must use a switch statement for this exercise.

2. Compile and test your program to ensure that it performs as specified.

More products