458,247 Members | 1,746 Online Need help? Post your question and get tips & solutions from a community of 458,247 IT Pros & Developers. It's quick & easy.

# i need help:""<

 P: n/a hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes #these are the operations [a, b] + [c, d] = [a+c, b+d], [a, b] - [c, d] = [a-d, b-c], [a, b] * [c, d] = [min(ac, ad, bc, bd), max(ac, ad, bc, bd)], 1/[a, b] = [1/b, 1/a] only if 0 not in [a,b]. & the Question is to Write the class interval that has lower and upper as data members, set, get, print, and constructors as member functions. The class also has the four member functions add, subtract, multiply, and divide. Implement the class members, and write a driver that declares two objects of the class interval and prints the results of the four operations on the two declared objects. Sample input / output: Enter the lower and upper limits of the first interval: 2 8 [2, 8] Enter the lower and upper limits of the second interval: 3 6 [3, 6] The sum of the two intervals is: [5, 14] The subtraction of the two intervals is: [-4, 5] The multiplication of the two intervals is: [6, 48] The reciprocal of the first interval is: [0.5, 0.125] this is my prog #include #include using namespace std; class interval { int lower; int upper; void set(int,int)const; void get (int,int); void print(); void addtion(int,int,int,int); void subtract(int,int,int,int); void mutiplty(int,int,int,int); void divide(int,int,int,int); }; int main() { interval first,second; int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin>>first.l>>first.u; cout<>second.l>>second.u; cout<
10 Replies

 P: n/a "CuTe_Engineer" writes: i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes #these are the operations [a, b] + [c, d] = [a+c, b+d], [a, b] - [c, d] = [a-d, b-c], [a, b] * [c, d] = [min(ac, ad, bc, bd), max(ac, ad, bc, bd)], 1/[a, b] = [1/b, 1/a] only if 0 not in [a,b]. & the Question is to Write the class interval that has lower and upper as data members, set, get, print, and constructors as member functions. The class also has the four member functions add, subtract, multiply, and divide. Implement the class members, and write a driver that declares two objects of the class interval and prints the results of the four operations on the two declared objects. Sample input / output: Enter the lower and upper limits of the first interval: 2 8 [2, 8] Enter the lower and upper limits of the second interval: 3 6 [3, 6] The sum of the two intervals is: [5, 14] The subtraction of the two intervals is: [-4, 5] The multiplication of the two intervals is: [6, 48] The reciprocal of the first interval is: [0.5, 0.125] this is my prog #include #include using namespace std; class interval { int lower; int upper; Private: That's the first error I note. The lack makes the functions private. void set(int,int)const; void get (int,int); void print(); void addtion(int,int,int,int); void subtract(int,int,int,int); void mutiplty(int,int,int,int); void divide(int,int,int,int); }; int main() { interval first,second; int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin>>first.l>>first.u; cout<>second.l>>second.u; cout<

 P: n/a On Sep 14, 8:47 pm, Erik Wikström #include using namespace std; class interval { int lower; int upper; public: interval(int l, int u); Do not forget the constructor. void set(int,int)const; Not const, see below for explanation. void get (int,int); Will not work, see below. void print(); void print() const; void addtion(int,int,int,int); void add(const interval&) const; void subtract(int,int,int,int); void subtract(const interval&) const; void mutiplty(int,int,int,int); void multiply(const interval&) const; void divide(int,int,int,int); void divide(const interval&) const; }; int main() { interval first,second; Remove those, you (now) have a constructor, make sure to also use it. int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin >l >u; interval first(l, u); cout<<"["< { int add1,add2; add1=first.l+second.l; add2=first.u+second.u; } And you should use the constructor to create the new object. The same goes for the rest of the functions.( can you show me how i don`tknow how to use constuctor*) void interval::print() const { cout<<"The sum of the two intervals is: [ "<

 P: n/a On Sep 15, 4:40 am, CuTe_Engineer #include using namespace std; class interval { int lower; int upper; public: interval(int l, int u); Do not forget the constructor. void set(int,int)const; Not const, see below for explanation. void get (int,int); Will not work, see below. void print(); void print() const; void addtion(int,int,int,int); void add(const interval&) const; void subtract(int,int,int,int); void subtract(const interval&) const; void mutiplty(int,int,int,int); void multiply(const interval&) const; void divide(int,int,int,int); void divide(const interval&) const; }; int main() { interval first,second; Remove those, you (now) have a constructor, make sure to also use it. int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin >l >u; interval first(l, u); cout<<"["<

 P: n/a On 2007-09-14 23:40, CuTe_Engineer wrote: On Sep 14, 8:47 pm, Erik Wikström On 2007-09-14 15:06, CuTe_Engineer wrote: hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes #these are the operations [a, b] + [c, d] = [a+c, b+d], [a, b] - [c, d] = [a-d, b-c], [a, b] * [c, d] = [min(ac, ad, bc, bd), max(ac, ad, bc, bd)], 1/[a, b] = [1/b, 1/a] only if 0 not in [a,b]. & the Question is to Write the class interval that has lower and upper as data members, set, get, print, and constructors as member functions. The class also has the four member functions add, subtract, multiply, and divide. Implement the class members, and write a driver that declares two objects of the class interval and prints the results of the four operations on the two declared objects. Sample input / output: Enter the lower and upper limits of the first interval: 2 8 [2, 8] Enter the lower and upper limits of the second interval: 3 6 [3, 6] The sum of the two intervals is: [5, 14] The subtraction of the two intervals is: [-4, 5] The multiplication of the two intervals is: [6, 48] The reciprocal of the first interval is: [0.5, 0.125] this is my prog #include #include using namespace std; class interval { int lower; int upper; public: interval(int l, int u);Do not forget the constructor. void set(int,int)const; Not const, see below for explanation. void get (int,int); Will not work, see below. void print(); void print() const; void addtion(int,int,int,int); void add(const interval&) const; void subtract(int,int,int,int); void subtract(const interval&) const; void mutiplty(int,int,int,int); void multiply(const interval&) const; void divide(int,int,int,int); void divide(const interval&) const; }; int main() { interval first,second; Remove those, you (now) have a constructor, make sure to also use it. int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin >l >u; interval first(l, u); cout<<"["<> { int add1,add2; add1=first.l+second.l; add2=first.u+second.u; } And you should use the constructor to create the new object.The same goes for the rest of the functions.( can you show me how i don`t know how to use constuctor*) >void interval::print() const { cout<<"The sum of the two intervals is: [ "<

 P: n/a On 2007-09-14 23:48, CuTe_Engineer wrote: On Sep 15, 4:40 am, CuTe_Engineer On Sep 14, 8:47 pm, Erik Wikström #include using namespace std; class interval { int lower; int upper; public: interval(int l, int u); Do not forget the constructor. void set(int,int)const; Not const, see below for explanation. void get (int,int); Will not work, see below. void print(); void print() const; void addtion(int,int,int,int); void add(const interval&) const; void subtract(int,int,int,int); void subtract(const interval&) const; void mutiplty(int,int,int,int); void multiply(const interval&) const; void divide(int,int,int,int); void divide(const interval&) const; }; int main() { interval first,second; Remove those, you (now) have a constructor, make sure to also use it. int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin >l >u; interval first(l, u); cout<<"["<

 P: n/a On 2007-09-14 23:40, CuTe_Engineer wrote: On Sep 14, 8:47 pm, Erik Wikström On 2007-09-14 15:06, CuTe_Engineer wrote: hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes #these are the operations [a, b] + [c, d] = [a+c, b+d], [a, b] - [c, d] = [a-d, b-c], [a, b] * [c, d] = [min(ac, ad, bc, bd), max(ac, ad, bc, bd)], 1/[a, b] = [1/b, 1/a] only if 0 not in [a,b]. & the Question is to Write the class interval that has lower and upper as data members, set, get, print, and constructors as member functions. The class also has the four member functions add, subtract, multiply, and divide. Implement the class members, and write a driver that declares two objects of the class interval and prints the results of the four operations on the two declared objects. Sample input / output: Enter the lower and upper limits of the first interval: 2 8 [2, 8] Enter the lower and upper limits of the second interval: 3 6 [3, 6] The sum of the two intervals is: [5, 14] The subtraction of the two intervals is: [-4, 5] The multiplication of the two intervals is: [6, 48] The reciprocal of the first interval is: [0.5, 0.125] this is my prog #include #include using namespace std; class interval { int lower; int upper; public: interval(int l, int u);Do not forget the constructor. void set(int,int)const; Not const, see below for explanation. void get (int,int); Will not work, see below. void print(); void print() const; void addtion(int,int,int,int); void add(const interval&) const; void subtract(int,int,int,int); void subtract(const interval&) const; void mutiplty(int,int,int,int); void multiply(const interval&) const; void divide(int,int,int,int); void divide(const interval&) const; }; int main() { interval first,second; Remove those, you (now) have a constructor, make sure to also use it. int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin >l >u; interval first(l, u); cout<<"["<

 P: n/a On Sep 15, 5:49 am, Erik Wikström #include using namespace std; class interval { int lower; int upper; public: interval(int l, int u); Do not forget the constructor. void set(int,int)const; Not const, see below for explanation. void get (int,int); Will not work, see below. void print(); void print() const; void addtion(int,int,int,int); void add(const interval&) const; void subtract(int,int,int,int); void subtract(const interval&) const; void mutiplty(int,int,int,int); void multiply(const interval&) const; void divide(int,int,int,int); void divide(const interval&) const; }; int main() { interval first,second; Remove those, you (now) have a constructor, make sure to also use it. int l,u; cout<<"Enter the lower and the upper limits of the first interval"; cin >l >u; interval first(l, u); cout<<"["< #include using namespace std; class interval { public: interval(); interval(int ,int ); void set(int,int); void print() const; void addittion(const interval&) const; void subtract(const interval&) const; void multiply(const interval&) const; void divide(const interval&) const; void set(int,int); void get(int&,int&); private: int lower; int upper; }; int main() { interval interval1, interval interval2(3,6), cout<<"Enter the lower and the upper limits of the first interval"; cin>>lower>>upper; interval1.set(2,8) cout<>lower>>upper; interval2.set(3,6) cout< 