Answer to Question #271244 in C++ for Sami khattak

Question #271244

write a class with name “STRING”.Assume only studio.h library is included and it is not possible to include any other library. In PRIVATE section of class there will be a character array (lets say S) and also it is possible to locate functions to this section that you want to use but not asked. In public section there will be five functions.

  1. ”set” function will take a character array as parameter and assign it to ‘S’
  2. ’print’ function will just print ‘S’ on screen
  3. ’count’ function will take character as parameter and count the first appearance of that character by counting from right and return this count number
  4. ’show’ function prints consonants in ‘S’ on screen (vowels : i,o,u,e,a)
  5. prefix - - operator will delete the first character of ‘S’
1
Expert's answer
2021-11-26T07:08:35-0500

SOLUTION CODE

#include<studio.h>
using namespace std;


class STRING {
   
private: 
	char S;
  
public:
	 char set_S [6] = {'S','T','R','I','N','G'};
		
		 //cout<<S[0] <<"\n";
	string count (string S) {
		 int res = 0;
 
    for (int i=0;i<6;i++)
 
        //if (S[i] == S)
            res++;
 
    //return res;
    
}
void showCharacterType(string S)
{


	
    int vowels = 0;
    for (int j = 0; j < S.length(); j++) {
          char S;
        
         if ( (S >= 'S' && S <= 's') ||
              //(T >= 'T' && T <= 't') ||
			  //(R >= 'R' && R <= 'r') ||
			  //(I >= 'I' && I <= 'i') ||
			  //(N >= 'N' && N <= 'n') ||
			  //(G >= 'G' && G <= 'g') ) {
 
            S = tolower(S);
            vowels++;
	}
	cout << "Vowels: " << vowels << endl;


int main()
{
    string str = ‘STRING’;
    countCharacterType(str);
    str.erase ([0]); 
    return 0;
}


}
}
}
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Sami
26.11.21, 14:12

Thank you so much , really helpfull website , really good

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS