PDA

View Full Version : C++ help


osmoses-jones
2006-10-28, 04:10 PM
I have to write a c++ programe that calculate how much paint cans you need to paint a rooms. each rooms have about 12 feet x 10 feet with 8 foot ceilings. each room contains 4foot x 5 foot window and a 3 foot x 7 door. in programe i have to ask the user how much door and windows in room. Can anyone help me

Lenny
2006-10-28, 04:12 PM
How big an area can each paint can paint? And is it just the walls you paint?

Demosthenes
2006-10-28, 06:41 PM
Seems rather straightforward. What exactly do you seem to be having problems with? And like Lenny said, how much area can the cans paint?

osmoses-jones
2006-10-30, 05:09 PM
here lab teacher gave us i don't know how to start it up.

http://img.photobucket.com/albums/v445/mutombo9890/afasgasg.jpg

Lenny
2006-10-31, 09:37 AM
Sure he didn't tell you how big an area each can paints?

It could be that a can paints 175 square feet, or it could be that the second wasn't fully used as both paint 200 square feet.

I don't know C++, but if it was done in VB you'd declare your variables, right? I guess that there is a similar thing done in C++?

Medieval Bob
2006-10-31, 09:50 AM
Ya your teacher needs to tell you the coverage of a paint can. By that information, a can of paint could cover 349 square feet of room.

Damn I wish I was back at this level... *sigh*

Anyhow, for your program, you'll have something like this. (This is just pseudocode; don't copy it straight, because it won't work)

int totalarea
int doorarea
int windowarea
int paintablearea
int numdoors
int numwindows
int numcans

totalarea = 8 * 10 * 12

cout << how many doors?
cin >> numdoors
doorarea = numdoors * 3 * 7

cout << how many windows?
cin >> numwindows
windowarea = numwindows * 4 * 5

paintablearea = totalarea - (doorarea + windowarea)

numcans = ceil(paintablearea / WHATEVER A CAN PAINTS)
cout << The number of cans you'll need is << numcans

Demosthenes
2006-11-01, 01:14 PM
Also, how is the area of the room 472 if its about 12 x 10 feet in size?

Lenny
2006-11-01, 02:41 PM
12 down one side, 10 down the other, 8 high.

2(12 x 8) + 2(10x8) = 352 ---> walls

12x10 = 120 -----> Ceiling

352 + 120 = 472 ----> total paintable area as the floor cannot be painted.

Medieval Bob
2006-11-01, 03:04 PM
Well hell don't give him all the answers. [/hypocrite]

I was hoping he'd convert my pseudocode, get a ridiculously high number, and then sit down to figure out why it's wrong and how to make it work.

Demosthenes
2006-11-01, 03:06 PM
Well, it says Room is 472 square feet in size. Generally square footage of a room is the area of the floor in the room, which can not possibly be 472 square feet.

Lenny
2006-11-01, 03:19 PM
Sorry, Bob.

---

I know what you mean, MJ. It should really be paintable Surface Area. But who are we to correct a teacher's failings?

osmoses-jones
2006-11-01, 07:26 PM
ty bob i figure out how now. to find the number of cans i have to divide paintarea by 250. I got my teacher lab yay thank you god i better learn c++ fast or i will be confuse next quarter when i get to work with torque engine.

Lenny
2006-11-02, 03:23 PM
What are the major differences between C++ and VB?

If you know how to do everything in VB, and know what the same functions would be in C++, then would you be able to write C++ programs using a VB one as a base?

Demosthenes
2006-11-02, 04:17 PM
What are the major differences between C++ and VB?

If you know how to do everything in VB, and know what the same functions would be in C++, then would you be able to write C++ programs using a VB one as a base?

You could use the same functions in a C++ program as you could in a VB program via DLL's, I believe. Syntactically, they're a bit different, so simply knowing VB would not allow you to code in C++, but I don't think it would be too difficult to pick up on it. I believe you can write functions in C++, put them in DLLs and then use those functions on a VB program. As for simply continuing a VB program in C++, I wouldn't be surprised if it is possible, although I have no earthly idea how to do it. I don't know VB, though, so don't quote me on any of this. I've only dabbled around with it.

Medieval Bob
2006-11-02, 06:56 PM
VB is missing a good bit of the functionality of C++ is because of its simplicity. You can do anything that you can do in VB in C++ and vice versa, but typically complex programs aren't written in VB. VB isn't very well adapted to object oriented programming. And finally, C++ is much faster.

Lenny
2006-11-03, 10:31 AM
I see.

So how easy is C++ to learn:

a) With no prior experience with any programming language?
b) With experience with things like VB?

Demosthenes
2006-11-03, 01:18 PM
You can do anything that you can do in VB in C++ and vice versa,

Can you do system level programming and such with VB?

a.) Lenny, C was the first language I picked up on, which is not so dissimilar from C++. It was not difficult at all.

b.) It would help considerably.

Lenny
2006-11-03, 01:40 PM
Rightyho.

Methinks that once I know my way around VB like the back of my hand, I'll have a crack at C++.

Medieval Bob
2006-11-03, 11:43 PM
If you can write it in C++, you can write it in VB. Your implementation may have to be different, but you can get all the same functionality.

Demosthenes
2006-11-03, 11:46 PM
If you can write it in C++, you can write it in VB. Your implementation may have to be different, but you can get all the same functionality.

I thought that pointers and such are restricted in VB. For instance, if I wanted to write directly to the video buffer, how would I accomplish this in VB? I don't know though, I don't know VB at all, I just heard that pointers were severely limited in VB.

Medieval Bob
2006-11-04, 09:37 AM
Pointers are allowed but limited in use. Of course, I'm not a VB guru or anything. Mantra knows his shit. Ask him.

WetWired
2006-11-04, 12:00 PM
VB does not have pointers; it has references.

osmoses-jones
2006-11-04, 02:51 PM
ok i have encounter with another problem plz help. I have to write a structure progame that have two char of arrays one for first name and one for last name a character variable to store the middle initial and an integer variable to store the age. here what i got so far
#include <iostream.h>

struct Name

{
char FirstName[20];
char MiddleName;
char LastName[20];
int Age;
};

ok the problem is i have to pass structure name to a function named FillStructure and fill it there. Anyone know how. i keep looking my school book and deosn't help.

Medieval Bob
2006-11-04, 03:58 PM
You don't think a reference is close enough to a pointer to simply call it one?

Anyhow, additionally:
http://www.codeproject.com/useritems/UB_Pointers_In_VB.asp?df=100&forumid=30362&exp=0&select=696597
http://www.codeproject.com/vbscript/how_to_do_pointers_in_visual_basic.asp

Medieval Bob
2006-11-04, 03:59 PM
How would you pass an int (int thisIsAnInteger) to a function (FillStructure) ?

Mantralord
2006-11-04, 05:30 PM
VB does not have pointers; it has references.

there are pointers in the sense that you can get a variable/function address and hold that in another variable, but there's none of that convenient pointer arithmetic