مساء الخير
هذا سؤال حليته لكن الرن مو مضبوط ارجو المساعده
جزاكم الله خيرا
هذا هو السؤال
Write a word processing program that reads a given text of any length no less than 100 characters, then displays a menu to choose and perform one of the following tasks:
2- Changing case: once this option is selected, a sub menu is displayed to allow user to choose the way of changing case of characters in the text:
lower case: changes the case of all characters in the text to small letters
UPPER CASE: changes the case of all characters in the text to capital letters
Title Case: changes the case of first character in each word in the text to the capital letter and the remaining characters to small letters
tOGGLE cASE: changes the case of first character in each word in the text to the small letter and the remaining characters to capital letters
وهذا هو الكود
/*
Write a word processing program that reads a given text of any length no less than 100 characters, then displays a menu to choose and perform one of the following tasks:
1- Changing case: once this option is selected, a sub menu is displayed to allow user to choose the way of changing case of characters in the text:
§ lower case: changes the case of all characters in the text to small letters
§ UPPER CASE: changes the case of all characters in the text to capital letters
§ Title Case: changes the case of first character in each word in the text to the capital letter and the remaining characters to small letters
§ tOGGLE cASE: changes the case of first character in each word in the text to the small letter and the remaining characters to capital letters
*/
#include <iostream>
#include <string>
using namespace std;
int main () {
char x [200];
bool Q=true , loop=true ;
int option ;
int counter=0;
int size=0;
cout<<"Enter u phearse .... any length no less than 100 characters : "<<endl;
cin>>x;
while (x)
{
size++;
}
while(Q){ // to must Enter 100 char ..........................
if ( !(size < 100) )
Q=true;
else
{cout<<"Enter u phearse .... any length no less than 100 characters : "<<endl;
cin>>x;}
}
cout<<"***********Plz choise from 1 to 5 ************"<<endl;
cout<<"1-lower case: changes the case of all characters in the text to small letters"<<endl;
cout<<"2-UPPER CASE: changes the case of all characters in the text to capital letters"<<endl;
cout<<"3-Title Case: changes the case of first character in each word in the text to the capital letter and the remaining characters to small letters"<<endl;
cout<<"4-tOGGLE cASE: changes the case of first character in each word in the text to the small letter and the remaining characters to capital letters"<<endl;
cout<<"5-Exit"<<endl;
cin>>option;
while(loop){
switch (option) {
case 1:
{
//lower case --------------------------
while (x[counter])
{
x[counter]=tolower(x[counter]);
counter++;
}
cout<<x<<endl;
counter=0;
//-------------------------------------
break ;
}
case 2:
{
// upper case -------------------------
while (x[counter])
{
x[counter]=toupper(x[counter]);
counter++;
}
cout<<x<<endl;
counter=0;
//-------------------------------------
break ;
}
case 3:
{
//Title Case---------------------------
while (x[counter])
{
if ( x[counter] == ' ' ){
x[counter+1]=toupper(x[counter+1]);
counter++;
}
else
x[counter]=tolower(x[counter]);
counter++;
}
cout<<x<<endl;
counter=0;
//-------------------------------------
break ;
}
case 4:
{
//tOGGLE cASE ---------------------------
while (x[counter])
{
if ( x[counter] == ' ' ){
x[counter+1]=tolower(x[counter+1]);
counter++;
}
else
x[counter]=toupper(x[counter]);
counter++;
}
cout<<x<<endl;
counter=0;
break ;
}
case 5:{
loop=false;
break;}
default :
cout << " plz Enter correct number .. try again .... " << endl;
}// end switch
}// end while ...................
return 0;
}
