dimanche 18 septembre 2022

Need some help on this problem to merge these two codes

 #include <iostream>
using namespace std;
int main()
{
    char c;
    int n;
    cout << " Please enter a letter of the Alphabet and a decimal number";
    cin >> c >> n;
    if (c == 'a'|| c== 'e'|| c== 'i'|| c== 'o'|| c== 'u'||c == 'A'|| c== 'E'|| c== 'I'|| c== 'O'|| c== 'U' )
    {
        cout << c <<  " is a vowel" << endl;
    }
    else
    {
        cout << c << " is a consonant" << endl;
    }

    float x;
    cin >> x;
        if (x<0)
            cout << x << " is less than 0";
        else if (x>0&&x<100)
            cout << x << " is in range ";
        else
            cout << x << " is out of bounds";

        return 0;
}

The output is this when A, 41.5 is entered:

A is a vowel nan is out of bounds.

I would like for the code to be able to find the answer to both and tell me whether or not it is below 0, in range, or out of bounds and also say that the letter is a vowel or a consonant, how could I go about doing this?

Aucun commentaire:

Enregistrer un commentaire