My job is write a program what converts a sentence into lower and upper case.
#include <iostream>
using namespace std;
int main ()
{
int current;
string sent;
cout << "Please enter a sentence: ";
cin >> sent;
for (int i = 0; i < sent.length(); i++)
{
current = (int) sent[i];
cout << "Your sentence in all lower case: "<< sent;
cout << endl;
if (current >= 65 && current <= 90)
{
current += 32;
sent[i] = (char) current;
cout << "Your sentence in all upper case: " << sent;
}
}
return 0;
}
The output should be:
Please enter a sentence: I Eat Apples!
Sentence in all lower case: i eat apples!
Sentence in all upper case: I EAT APPLES!
However I keep getting a lowercase "i" for the lower case and the upper case I get an upper case I, how come my code doesn't print out the full sentence? I don't get what I did wrong or where the wrong doing is.