Hi, ive only started programming recently and as my second assignment i have to write a program that can convert uppercase letters to lowercase letters and visa-versa. i also have to make it stop when a full-stop is entered and count the number of times the program changed letter case.

i have it all written but i dont know how to count the number of times the letter changed case.

could you please help me.

Here is what i have so far:

#include <iostream>
using namespace std; 

int main () 
{

    char choice;    
    cout << "Enter a full stop to end the program" << endl;

    do{
    cout << "Enter the letter you want to be converted:";  
    cin >> choice;


    if
    ((choice>=97)&&(choice<=122))
    {
    choice=choice-32;
    cout<<"The upper case letter corresponding is:" << choice << endl;
    }

    else if
    ((choice>=65)&&(choice<=90))
    {
    choice=choice+32;
    cout << "The lower case letter corresponding is:" << choice << endl;
    }

    else 
    {
    cout << choice <<" is not a letter!!" << endl;
    }
    }
    while (choice != 46);

    return 0;
}

PS its not actually in green in my program, thats just to make it easier to see what my program is.

thanks

Declare an integer counter at the start of the program, increment it every time you change case, at the end of while loop read the value of the counter.

To post code use the code tags

. This will properly indent your code and make it easier to read.

-- Double post --

thank you very much, that worked perfectly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.