Private Messages Options Search Blogs Images Chat Cam Portals Calendar FAQ's Join  
Asylum Forums : Powered by vBulletin version 2.2.8 Asylum Forums > WIT - Whore Institute of Technology > C++ help (again)
  Last Thread   Next Thread
Author
Thread [new thread]    [post reply]
SocialParasite
100% pure failtanium.

Registered: Jul 2000
Location: Beatrice, Nebraska
Posts: 18490

Post C++ help (again)

Okay, until I get this damn unit finished, I'm gonna be asking for a bit of help. I almost had this damn code up and running, but I kept hitting snags that I can't get myself around. I'm still not a l33t code guy.

quote:

#include <iostream.h>
int main()

{
double weight;
double length;
double width;
double height;
bool heavy, volume;



cout << "--- How big is your package? ---" <<endl;
cout << endl <<endl;
cout << "Enter weight of package in kilograms: ";
cin >> weight;
cout << "Enter length of package in meters: ";
cin >> length;
cout << "Enter width of package in meters: ";
cin >> width;
cout << "Enter height of package in meters: ";
cin >> height;
double vol;
vol = (length*width*height);

if (weight > 27)
heavy = false;
else if (weight <= 27)
heavy = true;

if (vol > .1)
volume = false;
else if (vol <= .1)
volume = true;

{
if (heavy = true && volume = false)
cout << "Package rejected: Too heavy." <<endl;
else if (heavy = false && volume = true)
cout << "Package rejected: Too large." <<endl;
else if (heavy = true && volume = true)
cout << "Package rejected: Too heavy and too large." <<endl;
}
else
cout << "Package accepted." <<endl;
return(0);
}



When I cut and pasted this, it was all indented. I don't know how it will come out here.

I know the error is probably something real simple, but I can't figure it out.

------------------
Have a good day, and if you feel like subjecting your genitals to high doses of x-ray radiation I'm sure the world will kindly thank you.

Report this post to a moderator | IP: Logged

Old Post 03-01-2001 11:00 PM
SocialParasite is offline Click Here to See the Profile for SocialParasite Click here to Send SocialParasite a Private Message Visit SocialParasite's homepage! Find more posts by SocialParasite Add SocialParasite to your buddy list [P] Edit/Delete Message Reply w/Quote
Dingle
Prison Rapemaster

Registered: Jul 2000
Location: Minneapolis, MN
Posts: 10178

Post

your using the assignment operator(=) for comparison, you need to use the comparison operator(==)

if (heavy = true && volume = false)
youre assigning true to heavy and false to volume rather than comparing, needs to be
if (heavy == true && volume == false)

Report this post to a moderator | IP: Logged

Old Post 03-02-2001 04:36 AM
Dingle is offline Click Here to See the Profile for Dingle Click here to Send Dingle a Private Message Find more posts by Dingle Add Dingle to your buddy list [P] Edit/Delete Message Reply w/Quote
SocialParasite
100% pure failtanium.

Registered: Jul 2000
Location: Beatrice, Nebraska
Posts: 18490

Post

I should have caught that, and would have, if I had just five more minutes of class to work in.

So, the code should work fine otherwise?

------------------------
Have a good day, and if you feel like subjecting your genitals to high doses of x-ray radiation I'm sure the world will kindly thank you.

Report this post to a moderator | IP: Logged

Old Post 03-02-2001 04:55 AM
SocialParasite is offline Click Here to See the Profile for SocialParasite Click here to Send SocialParasite a Private Message Visit SocialParasite's homepage! Find more posts by SocialParasite Add SocialParasite to your buddy list [P] Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 08:52 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

< Contact Us - The Asylum >

Powered by: vBulletin Version 3.0.6
Copyright ©2000 - 2002, Jelsoft Enterprises Limited.
Copyright © 2000- Imaginet Inc.
[Legal Notice] | [Privacy Policy] | [Site Index]