Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include declare.h int a; int b; int r; integer::integer() { } integer::integer(int y) {// constaructor with para Digit = y; } integer::~integer() { } //part

#include "declare.h" int a; int b; int r; integer::integer() { } integer::integer(int y) {// constaructor with para Digit = y; } integer::~integer() { } //part b to put set and gets int integer::getIntNum() { return Digit;//getting the Digit to return } void integer::setIntNum(int y) {//set method to intilize the memeber variable Digit = y; } //part c wants us to have add,mult,sub,div in the class void integer::add() {//simple function to add r = a + b; } void integer::sub() {//simple function to sub r = a - b; } void integer::mult() {//simple fucntion to mult r = a * b; } void integer::divide() {//simple fucntion for div r= a / b; }; ///////// #include "declare.h" int a; int b; int r; integer::integer() { } integer::integer(int y) {// constaructor with para Digit = y; } integer::~integer() { } //part b to put set and gets int integer::getIntNum() { return Digit;//getting the Digit to return } void integer::setIntNum(int y) {//set method to intilize the memeber variable Digit = y; } //part c wants us to have add,mult,sub,div in the class void integer::add() {//simple function to add r = a + b; } void integer::sub() {//simple function to sub r = a - b; } void integer::mult() {//simple fucntion to mult r = a * b; } void integer::divide() {//simple fucntion for div r= a / b; }; //////// #include #include "declare.h" using namespace std; integer fObj; integer sObj; integer rObj; char operation; int main() { const int A = 0; const int B = 1; const int C = 2; const int D = 3; const int E = 4; int y = 0; int s = 0; while (operation != E) { cout << "choose A=add, B=sub, C=mult, D=div, and E if you want to exit." << endl; cin >> operation; switch (operation) { case A: cout << "Choose any number to add..." << endl; fObj.setIntNum(y); sObj.setIntNum(s); rObj.add(); cout << "Answer: " << rObj.getIntNum() << endl; case B: cout << "Choose any number to sub..." << endl; fObj.setIntNum(y);//SETS THE VALUE TO WHAT THE USER WANTS sObj.setIntNum(s); rObj.sub(); cout << "Answer: " << rObj.getIntNum() << endl; case C: cout << "Choose any number to mult..." << endl; fObj.setIntNum(y); sObj.setIntNum(s); rObj.divide(); cout << "Answer: " << rObj.getIntNum() << endl; case D: cout << "Choose any number to div..." << endl; fObj.setIntNum(y); sObj.setIntNum(s); rObj.mult(); cout << "Answer: " << rObj.getIntNum(); case 5: cout << "Exiting" << endl; break; } } } I CANT FIGURE OUT WHY I KEEP GETTING A LOOP OF (choose A=add, B=sub, C=mult, D=div, and E if you want to exit.) AND I CANT DO NOTHING. I GAVE U MY WHOLE SOURCE CODE. PLEASE CHECK AND GIVE ME A FIX THNAK YOU.

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

Fundamentals of Cost Accounting

Authors: William Lanen, Shannon Anderson, Michael Maher

4th edition

78025524, 978-0078025525

Students also viewed these Databases questions