1.

A class Magic enables the user to accept a word and checks for Magic word.A Magic word is one which has consecutive alphabets within itself at any position. -Example: MYSTERY has consecutive letters ST and is a Magic word.LAB, PQ, XY, ZA... are some examples of consecutive alphabetsSome of the members of the class are given below:Class nameMagicData members/instance variables::to store the wordstrMember functions/methods::default constructorMagic():to accept a word in UPPER casevoid input():boolean check()checks and returns true if the word is a Magicword otherwise returns false:void display():displays the word with an appropriate messageDefine the class Magic giving details of the constructor( ), void input().boolean check() and void display ( ). Define the main() function to create an object andcall the functions accordingly to enable the task.​

Answer»

Explanation:

Magic enables the user to accept a word and checks for Magic word.

A Magic word is one which has consecutive alphabets within itself at any position. -

Example: MYSTERY has consecutive letters ST and is a Magic word.

LAB, PQ, XY, ZA... are some examples of consecutive alphabets

Some of the members of the class are given below:

Class name

Magic

Data members/instance variables:

:

to STORE the word

str

Member FUNCTIONS/methods:

:

default constructor

Magic()

:

to accept a word in UPPER case

void input()

:

BOOLEAN check()

checks and RETURNS true if the word is a Magic

word otherwise returns false

:

void display():

displays the word with an appropriate message

Define the class Magic giving details of the constructor( ), void input().

boolean check() and void display ( ). Define the main() FUNCTION to create an object and

call the functions accordingly to enable the task



Discussion

No Comment Found