|
-
March 20th, 2009, 01:15 PM
#1
Need help with fixing C++ code?
Ok, here's the thing. I want to have a program that tells the user to enter the height and width of a poster.
Then i want it to (based on the user entered numbers) to tell the user to use A4, A3, A2 or A1 paper. Must reflect portrait and landscape view.
I'm new at C++, and so i want you to tell me what is wrong with the code I have so far, and show me how you fixed it (if you fixed it for me) or tell how to do it on my own.
I only want to use what I know so far for the code, so nothing for advanced C++ please .
Here is the code i have so far:
______
#include <iostream>
using namespace std;
int main()
{
int pos_wid, pos_hei;
cout << "Enter the dimensions of the poster in mm: " << endl;
cin >> pos_wid >> pos_hei;
if (pos_wid => 210 && pos_hei <= 297) || (pos_wid <= 297 && pos_hei => 210)
{
cout << "Use A4" << endl;
}
else if (pos_wid => 297 && pos_hei <= 420) || (pos_wid <= 420 && pos_hei => 297)
{
cout << "Use A3" << endl;
}
else if (pos_wid => 420 && pos_hei <= 594) || (pos_wid <= 594 && pos_hei => 420)
{
cout << "Use A2" << endl;
}
else if (pos_wid => 594 && pos_hei <= 810) || (pos_wid <= 810 && pos_hei => 594)
{
cout << "Use A1" << endl;
}
else
{
cout << "Not in stock" << endl;
}
system("pause>null");
}
______
Oh and please don't laugh if you find a lot of errors , like I said i'm new.
-
March 20th, 2009, 01:24 PM
#2
Re: Need help with fixing C++ code?
Did it compile?
Did you run it?
Did it work?
-
March 20th, 2009, 01:26 PM
#3
Re: Need help with fixing C++ code?
 Originally Posted by GCDEF
Did it compile?
Did you run it?
Did it work?
No.
Couldn't didn't work.
No.
-
March 20th, 2009, 01:30 PM
#4
Re: Need help with fixing C++ code?
Would be a good idea to tell what the compiler thinks about your code.
Anyway there is no operator =>. use >= instead.
Kurt
-
March 20th, 2009, 01:30 PM
#5
Re: Need help with fixing C++ code?
=> should be >=
For help with compiling problems, it's best to tell us what the errors are that you're getting.
Also, please use code tags.
-
March 20th, 2009, 01:36 PM
#6
Re: Need help with fixing C++ code?
i only corrected the first if.
Code:
if (((pos_wid >= 210) && (pos_hei <= 297)) || ((pos_wid <= 420) && (pos_hei >= 297)))
{
cout << "Use A4" << endl;
}
Last edited by Alin; March 20th, 2009 at 01:39 PM.
-
March 20th, 2009, 01:40 PM
#7
Re: Need help with fixing C++ code?
Looking at it again, I think you want <= 210, not >=.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|