Answer to Question #53592 in C++ for Chanel Maughmer

Question #53592
Use the CharRange class. The IntRange class should allow the user to enter integer values within a specified range. An error message should be displayed when the user enters a value outside the range. Demonstrate the class by wriiting a simple program that uses it. Could you write a simple program for this?
1
Expert's answer
2015-08-14T02:51:12-0400
Answer

#include <iostream>
using namespace std;

class intRange
{
private:
int n;
public:
void Range(long long int t)
{
if (t>32767||t<-32767)
{
cout<<"Error";
n=NULL;
}else {n=int(t); cout<<"Okay\n"<<n;};
}
intRange(long long int n)
{
Range(n);
}
};



int main()
{
intRange a(332676);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS