Problem with Beep(,)

I'm trying to make a program that allows the user to create a short tune. To do so I need to allow the user to type in two numbers (x and y) and combine both of those numbers into the Beep(,) function.

This is what I have:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cout << "Enter Note " << quantity << "." << endl;
cin >> chooser;
cin >> flatsharp;
cin >> length;
system("CLS");

if (chooser == 1) {
    if (flatsharp == 2) {
        if (length == 1) {
            Beep(233.08,100);
        } if (length == 2) {
........
.......
........
if statements on and on until all notes are done....


You probably already know what it does, but to make sure....
You enter what note you want (A, B, C, D, E, F, or G) it to play. Then you enter 1, 2, or 3 to make it flat, sharp, or normal. Afterwards, you enter the length you want it to be. It takes those values and puts them into billions of if statements until it finds a match.

I want to try and make it play all of those notes without billions of if statements. If you can help, please send me an email at: tyler.is.number.one@gmail.com or just post here.... :D
Last edited on
If you have lot of if statement then it is rewarding to use swich statement.

http://www.cplusplus.com/doc/tutorial/control/

In addition can you calculate the arguments of beep from parameter? So you shouldn't use if or switch statements...

For example you can calculate the second argument of beep (I think it is the length) form length variable.

length = length * 100; // length *=100;
Last edited on
So you mean i can type in Beep(chooser,length) and it will use the two variables inside the function? Let's say the user entered 200hz for the note, 1000 milliseconds for the length.

Example:
1
2
3
4
chooser=200;
length=1000;

Beep(chooser,length);


And that's all I gotta do? The program will play Beep(200,1000);?
Yes, as long as chooser/length are the correct types.
AWESOME THANKS GUY!!! ALL OF YOU!!!! IT WORKS! :D
Last edited on
Topic archived. No new replies allowed.