logancberrypie

Speaker program

Nov 16th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. using namespace std;
  5.  
  6. void sounds(string music);
  7. string Convert_upper(string word);
  8.  
  9. int main()
  10. {
  11.     string music;
  12.     cout << "Input string for playing" << endl;
  13.     getline(cin, music);
  14.     string upper = Convert_upper(music);
  15.     sounds(upper);
  16. }
  17.  
  18. string Convert_upper(string word)
  19. {
  20.     string final;
  21.     for (int i = 0;i<word.size();i++)
  22.     {
  23.         final += toupper(word[i]);
  24.     }
  25.     return final;
  26. }
  27.  
  28.  
  29. void sounds(string music)
  30. {
  31.     for (int i = 0;i<music.size();i++)
  32.     {
  33.         switch(music[i])
  34.         {
  35.         case 'A' : Beep(220,200);
  36.         case 'B' : Beep(250,200);
  37.         case 'C' : Beep(260,200);
  38.         case 'D' : Beep(300,200);
  39.         case 'E' : Beep(330,200);
  40.         case 'F' : Beep(350,200);
  41.         case 'G' : Beep(400,200);
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment