السلام عليكــم ورحمـة الله وبركاتــه
ارجوكم ساعدوني في كود
هذا السؤال
Write a C++ program that do the following:
a. Define a class called PowerOper that stores two pieces of information: the base and the exponent.
b. Define Set and Get functions for your class data members.
c. Define a member function called Power that prints the result of (base)power.
d. Define a member function called Validate that to check if exponent is a positive and nonzero integer.
e. The function Power should continue calling Validate before calculating the result until a valid exponent is entered by the user.
f. Define function Menu that print choices (i.e.1. calculate the power, 2. Exit). These choices must be repeated until the user selects exit. This function should call the corresponding calculating function based on the user's choice.
g. Declare an object of type Power and test your class.
وهذا الكود
المشكله انه ما يسوي run
#include <iostream>
#include <cmath>
using namespace std;
class PowerOper
{
private:
double base;
double exponent;
public:
void setbase(double d){
base=d;
}
void setexpon(double p){
exponent=p;
}
double getbase(){
return base;
}
double getexpon(){
return exponent;
}
double valid (double d){
do{
cout<<"enter valid exponent";
cin>>d;
}while (d<0);
return d;
}
void Power (double f,double d){
double h,powe;
h= double valid (double d);
powe=pow(d,h);
cout<<"power is "<<pow<<endl;
}
void mm (){
cout<<"1. calculate the power, 2. Exit ";
}
}
int main ()
{
PowerOper asd;
int y;
double d,f,k;
do {
asd.mm();
cout<<"enter you choice";
cin>>y;
cout<<"enter base";
cin>>f;
asd.setbase(double f)
cout<<"enter exponent";
cin>>k;
d=asd.double valid (double k);
asd.setexpon(double d);
Power (double f,double d);
}while(y!=2);
system("pause");
return 0;
}
وشكرااااااااااااااااااااااا
