Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please I need the coressponding .cpp file created for the given .h file. I have yet to write the main function for this class

C++ please

I need the coressponding .cpp file created for the given .h file.

I have yet to write the main function for this class

Nothing given can be changed

GENERAL RESTRICTIONS

No global variables

No labels or go-to statements

No infinite loops, examples include:

for(;;)

while(1)

while(true)

do{//code}while(1);

No break statements to exit loops

image text in transcribed

#ifndef Subtraction_h

#define Subtraction_h

#include

#include

using namespace std;

class Subtraction

{

//Overload the stream insertion and extraction operators

friend ostream& operator

public:

Subtraction();

//default constructor

//Postcondition: theAnswer=0; userResponse=0;

//invokes randomize();

void randomize();

//Function to generate two random numbers between 1 and 10.

//Postcondition: num1 and num2 are equal to between 1 and 10;

//and theAnswer = num1 - num2;

bool checkAnswer();

//Function to check userAnswer with problem answer (theAnswer)

//Postcondition: if theAnswer==userResponse appropriate feedback is displayed

// returns true if user answer is correct or returns false if user answer is incorrect;

void validate(string str1);

//Function to validate user response

//Postcondition: function accepts a string, validates it to be an int;

private:

int num1;//variable to store one of the operands

int num2;//variable to store one of the operands

int theAnswer;//variable to store the answer to the problem

int userResponse;//variable to store the user response to the problem in int format

};

#endif

1 #ifndef Subtractionh - #define Subtractionh - 4 #include 5 #include iostream 6 using namespace std; 8 class Subtraction 9 //OverLoad the stream insertion and extraction operators friend ostream& operator 5 #include iostream 6 using namespace std; 8 class Subtraction 9 //OverLoad the stream insertion and extraction operators friend ostream& operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago