Create a OOP that counts the number of times a particular letter shows up in the word search. Count how many times it came in the string. Use Inheritance.
Examples
letterCounter([
["D", "E", "Y", "H", "A", "D"],
["C", "B", "Z", "Y", "J", "K"],
["D", "B", "C", "A", "M", "N"],
["F", "G", "G", "R", "S", "R"],
["V", "X", "H", "A", "S", "S"]
], "D") ➞ 3
// "D" shows up 3 times: twice in the first row, once in the third row.
letterCounter([
["D", "E", "Y", "H", "A", "D"],
["C", "B", "Z", "Y", "J", "K"],
["D", "B", "C", "A", "M", "N"],
["F", "G", "G", "R", "S", "R"],
["V", "X", "H", "A", "S", "S"]
], "H") ➞ 2
#include
ReplyDeleteusing namespace std;
class B
{
public:
void check()
{
char searching = '\0';
string sentence = " ";
int counter = 1;
cout<<"Enter a sentence: "<>searching;
}
};
class B1: public B
{
public:
int i;
char searching = '\0';
int counter = 1;
string sentence = " ";
int res()
{
for(i=0; i<=sentence.length();i++)
{
if(sentence[i]==searching)
counter++;
}
cout<< " The letter " <<searching<< " appears " <<counter<< " times ";
return 0;
}
};
int main()
{
B1 obj;
obj.check();
obj.res();
}
//Faizah Akter
ReplyDelete//202010061
#include
using namespace std;
class B
{
public:
void check()
{
char searching = '\0';
string sentence = " ";
int counter = 1;
cout<<"Enter a sentence: "<>searching;
}
};
class B1: public B
{
public:
int i;
char searching = '\0';
int counter = 1;
string sentence = " ";
int res()
{
for(i=0; i<=sentence.length();i++)
{
if(sentence[i]==searching)
counter++;
}
cout<< " The letter " <<searching<< " appears " <<counter<< " times ";
return 0;
}
};
int main()
{
B1 obj;
obj.check();
obj.res();
}
Mahbubur rahman Limon
ReplyDeleteid: 202030070
#include
using namespace std;
class B
{
public:
void check()
{
char searching = '\0';
string sentence = " ";
int counter = 1;
cout<<"Enter a sentence: "<>searching;
}
};
class B1: public B
{
public:
int i;
char searching = '\0';
int counter = 1;
string sentence = " ";
int res()
{
for(i=0; i<=sentence.length();i++)
{
if(sentence[i]==searching)
counter++;
}
cout<< " The letter " <<searching<< " appears " <<counter<< " times ";
return 0;
}
};
int main()
{
B1 obj;
obj.check();
obj.res();
}
This comment has been removed by the author.
ReplyDeleteFariha sultana eity
ReplyDeleteId: 202010172
#include
using namespace std;
class B
{
public:
void check()
{
char searching = '\0';
string sentence = " ";
int counter = 1;
cout<<"Enter a sentence: "<<searching;
}
};
class B1: public B
{
public:
int i;
char searching = '\0';
int counter = 1;
string sentence = " ";
int res()
{
for(i=0; i<=sentence.length();i++)
{
if(sentence[i]==searching)
counter++;
}
cout<< " The letter " <<searching<< " appears " <<counter<< " times ";
return 0;
}
};
int main()
{
B1 obj;
obj.check();
obj.res();
}