473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

plzzzzzzzzzzzzzzzzzzzzzz help

#include<iostream>
#include<string>

using namespace std;

class interval
{

public:
void set(int,int);
void get (int &,int &) const;
void print() const;
void addtion(const interval &) const;
void subtract(const interval &) const;
void mutiplty(const interval &) const;
void divide(const interval &) const;
interval(int,int);

private:
int lower;
int upper;
int add1;
int add2;
int sub1;
int sub2;
int mul1;
int mul2;
double d1;
double d2;
};
int main()
{

interval first(l,u)
interval second(u,l);

cout<<"Enter the lower and the upper limits of the first interval";
cin>>l>>u;
cout<<"["<<l<<","<<u<<"]"<<endl;
cout<<endl;

first.set(l,u);

cout<<"Enter the lower and the upper limits of the second interval";
cin>>l>>u;
cout<<endl;
cout<<"["<<l<<","<<u<<"]"<<endl;

second.set(l,u);

first.addtion();
first.subtract();
first.mutiplty();
first.divide();
second.addtion();
second.subtract();
second.mutiplty();
second.divide();

print();
return 0;
}

interval::interval(int l, int u)
{
set (l,u);
}

void interval::set(int l,int u)
{
lower=l;
upper=u;
}

void interval::get(int & l,int & u) const
{
l=lower;
u=upper;
}

void interval::addtion(const interval &) const
{

add1=first.l+second.l;
add2=first.u+second.u;
}
void interval::subtract(const interval &) const
{
sub1=first.l-second.u;
sub2=first.u-second.l;
}

void interval::mutiplty(const interval &) const
{
int ac,ad,bc,bd;

ac=first.l*second.l;
ad=first.l*second.u;
bc=first.u*second.l;
bd=first.u*second.u;

mul1=min(ac,ad,bc,bd);
mul2=max(ac,ad,bc,bd);
}

void interval::divide(const interval &) const
{
if(first.l==0&&first.u==0)
cout<<"error"<<endl;

else
d1=1/first.l;
d2=1/first.u;
}

void interval::print() const
{
cout<<"The sum of the two intervals is:
[ "<<add1<<","<<add2<<"]"<<endl;
cout<<"The subtraction of the two intervals is:
[ "<<sub1<<","<<sub2<<"]"<<endl;
cout<<"The mutiplication of the two intervals is:
[ "<<mul1<<","<<mul2<<"]"<<endl;
cout<<"The reciprocal of the first interval is:
[ "<<d1<<","<<d2<<"]"<<endl;
}

Sep 19 '07 #1
7 1538
ka******@gmail.com wrote:

<Some code.>

Your z key is stuck.

Do you have a question?

--
Ian Collins.
Sep 19 '07 #2
<ka******@gmail.comwrote:

You have incredible patience, a good quality for a programmer.

The following compiles. The errors were numerous and I didn't mark them
I gutted the program by liberally inserting \\ to form comments and #if 0
#endif to eliminate larger blocks of stuff.

Get this working to your satisfaction, try to reason what was wrong, and put
the missing functions back in. The cin.get() were added simply to make my
compiler happy, they should be harmless to you, just be aware that they
*are* there when you run it.

#include<iostream>
#include<string>

using namespace std;

class interval
{

public:
void set(int,int);
void get (int &,int &) const;
void print() const;
void addtion(const interval &) ;
void subtract(const interval &) const;
void mutiplty(const interval &) const;
void divide(const interval &) const;
interval(int,int);

private:
int lower;
int upper;
int add1;
int add2;
int sub1;
int sub2;
int mul1;
int mul2;
double d1;
double d2;
};
int main()
{
int l, u;

interval first(l,u);
interval second(u,l);

cout<<"Enter the lower and the upper limits of the first interval";
cin>>l>>u;
cout<<"["<<l<<","<<u<<"]"<<endl;
cout<<endl;

first.set(l,u);
first.print();
cout<<"Enter the lower and the upper limits of the second interval";
cin>>l>>u;
cout<<endl;
cout<<"["<<l<<","<<u<<"]"<<endl;

second.set(l,u);

first.addtion(second);
first.print();
//first.subtract();
//first.mutiplty();
//first.divide();
//second.addtion();
//second.subtract();
//second.mutiplty();
//second.divide();


cin.get();
cin.get();

return 0;
}

interval::interval(int l, int u)
{
set (l,u);
}

void interval::set(int l,int u)
{
lower=l;
upper=u;
}

void interval::get(int & l,int & u) const
{
l=lower;
u=upper;
}
void interval::addtion(const interval & x)
{

lower = lower + x.lower; // long form for clarity
upper = upper + x.upper;
//add1=first.l+second.l;
// add2=first.u+second.u;
}

#if 0
void interval::subtract(const interval &) const
{
sub1=first.l-second.u;
sub2=first.u-second.l;
}

void interval::mutiplty(const interval &) const
{
int ac,ad,bc,bd;

ac=first.l*second.l;
ad=first.l*second.u;
bc=first.u*second.l;
bd=first.u*second.u;

mul1=min(ac,ad,bc,bd);
mul2=max(ac,ad,bc,bd);
}

void interval::divide(const interval &) const
{
if(first.l==0&&first.u==0)
cout<<"error"<<endl;

else
d1=1/first.l;
d2=1/first.u;
}
#endif
void interval::print() const
{

cout<< "lower:" << lower << '\n'
<< "upper:" << upper << endl;
#if 0
cout<<"The sum of the two intervals is:
[ "<<add1<<","<<add2<<"]"<<endl;
cout<<"The subtraction of the two intervals is:
[ "<<sub1<<","<<sub2<<"]"<<endl;
cout<<"The mutiplication of the two intervals is:
[ "<<mul1<<","<<mul2<<"]"<<endl;
cout<<"The reciprocal of the first interval is:
[ "<<d1<<","<<d2<<"]"<<endl;
#endif
}
Sep 19 '07 #3
"osmium" <r1********@comcast.netwrote:
You have incredible patience, a good quality for a programmer.
PS. I forgot to mention, you wrote too much code without testing. I would
hope that is obvious to you now.
Sep 19 '07 #4
<ka******@gmail.comwrote:
<snippage>
void interval::divide(const interval &) const
{
if(first.l==0&&first.u==0)
cout<<"error"<<endl;

else
d1=1/first.l;
d2=1/first.u;
}
That is not division, that is taking the reciprocal. The *example* from
your instructor wants to compute the reciprocal, but that has to be done in
main. The *function* performs division, not reciprocal. Get subtract
working. Test.Get multiply working. Test. Get divide working. Test. Get
reciprocal working. Test. Turn it in.
Sep 19 '07 #5
I have to submit this program tomorrow moring .......

plzzzzzzzz .. I wanna the solution if they don't mind :( :( :(

Sep 19 '07 #6
ka******@gmail.com wrote:
I have to submit this program tomorrow moring .......

plzzzzzzzz .. I wanna the solution if they don't mind :( :( :(
An answer is at
http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

Also see FAQ 5.7 on the same page.
Sep 19 '07 #7
thanx

Sep 19 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
10
by: Jacek Generowicz | last post by:
Where can I find concise, clear documentation describing what one has to do in order to enable Python's internal help to be able to provide descriptions of Python keywords ? I am in a situation...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
8
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.