jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, not a silly question at all. In your Form1.h, look about halfway down and you'll see the event handler "hookup" with the click event for each:

// button1
		// 
this->button1->Location = System::Drawing::Point(433, 290);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);

Use whatever method you want in the &Form1::button1_Click portion (it has to be a function with the same prototype as the click handler, that is with the object, EventArgs signature). Any one of your _Click methods will do. So say you had:

private: System::Void AllButtons_Click(System::Object^  sender, System::EventArgs^  e) {
				 //yada yada
				 }

You'd go through each of your buttons and change the last line of each of them to this->button1->Click += gcnew System::EventHandler(this, &Form1::AllButtons_Click); erasing the old buttonN_Click name.

The loop structure doesn't work because these methods are not meant to be invoked, but to respond to a event that happens in the window.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have hotmail and created a folder,but still counts the MB. I'll try to see if I can export these as text.

Check the specs on your account because last time I checked Hotmail had ever growing storage (they only give you 50 megs or something, but once you fill that they expand it in increments up to 5 gigs as needed).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're close - you need cin.getline() (you have the parameters basically correct) to take in the whole line.

Try the following test program to see if it helps you understand the other part of the problem:

char x = 'a';
char y = 'd';
char z = '9';
	
std::cout << y - x<<std::endl;
std::cout << ++y <<std::endl;
std::cout << z - '0' <<std::endl;

Test different values of the letters and look at http://web.cs.mun.ca/~michael/c/ascii-table.html for reference.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
What is your first name? Jim Bob
What is your last name? What letter grade do you deserve? C
What is your age? 100
Name: Jim, Bob
Grade: C
Age: 100

It's not working fine when I enter a first name with a space, it skips over the last name prompt completely. Hint, you can't use cin when you have a space as it uses a space as a marker to stop taking in characters.

WaltP has given you an important clue. First you need to modify your array approach, as it's unnecessary. Take in a regular char. A char is a 1-byte integer, and therefore you can perform arithmetic on it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The prompts are reversed for first and last name.

Also, test your program with a two word first name (like Betty Sue) and see what happens...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

have an empty mailbox once more

Or sponsor for a larger message quota. :) (Where's my commission, Dani?)

I thought she meant her own personal email, Happy, but maybe not.

happygeek commented: yay! +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here's a sample that moves a circle around the window when you press the button.

private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
{
    //get this event from the right hand side of the screen in the form design    
    //  window, click on the the lightening bolt and double click the cell next to 
     //the Paint()
				 
    Graphics ^ g = e->Graphics; //get the graphics handle from the form

    Random ^ rand = gcnew Random(); //random number generator

    g->DrawEllipse(gcnew Pen(Color::Black),
    Rectangle(rand->Next(0,ClientRectangle.Height),rand 
    ->Next(0,ClientRectangle.Width),10,10)); //make a circle in a 10x10 box at some 
//point over the window (box has upper left hand corner coordinate specified).  
//Sometimes it overlaps off the screen, but you get the idea

 //this normally requires a handle to a RectangleF (a rectangle with float coords), but this is an overload.
				 
}

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
{
   Invalidate(); //forces Paint() event to be called
}

(the lines are too long so it looks like hell, but you get the idea).

See if that gets you started in the right direction and you can start translating the Bob Powell tutorial (or one of your choosing) into C++. That graphics object holds all of the methods (drawellipse, fillellipse,etc.). The graphics object only comes from the Paint method, so you'll have to use Invalidate() in your other methods to control it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Finally, here is my question ***My e-mail In-box is full of Dani-Webs, not the Dani-Web In-box. I'm almost at maximum capacity. Without deleting these Dani-Webs or unsubscribing to them; how do I keep them without going over the maximum capacity?*** I created a special folder for this, but have the same problem.

That totally depends on what email program you use. There's usually a way to save to a folder locally or export some messages as text.

I see now, it's just a matter of keeping track of the post number to collapse/expand post.

Removing the post number forces the quote to be expanded all of the time (for us curmudgeons that liked that as the default). Simply quoting the text translates it to the box that can expand or contract.

Agapelove68 commented: Quotes I get it yea! Post, I don't yet, but your noparse trick worked! :) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need to do it in WPF (using that with C++ is one of those things that's theoretically possible, but not really doable anyway), the GDI+ stuff works in C++/CLI. I'll try to throw together a sample at some point.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Move displayPoll() outside of your while loop if you only want it to display once.

Also, main() is never void, it always returns an int.

I see what you are trying to do with the first element of the array. Well, make it of length 6 instead of 5 and all of those indexing issues go away.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I meant line 20, not line 26, sorry. But you are also trying to increment an element that's out of bounds on line 90. Your array elements go from 0 to 4 for a 5 element array. Fix that and I'll look at the rest of it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Now, is it a good idea to start by drawing all this do you think?

Are you asking if you have to implement the GUI? I would say that you probably don't.

The operator you want to focus on is == so that you have a way of evaluating whether two rectangles are equal (hint, you have their width and height as variables within the object) and whether two points are equal (their x's are equal and their y's are equal).

See if you can get some of the basic framework set up. Use an example from your text or one online.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is specifically wrong with the code?

Also, look at line 26, your array has 5 elements VoteArray[0],VoteArray[1],VoteArray[2],VoteArray[3],VoteArray[4] . Your loop is trying to access element 5 which doesn't exist.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

total, SIZE, and avg are all ints. Change avg to a double and cast either total or SIZE (or both) to a double. double avg = (double)total/SIZE; Even though avg is a double, the result of int/int division is in integer and therefore truncated.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It compiles fine apart from this and I am not sure if somehow I've coded it wrong, although then it should have thrown up compile errors? (Lost)!

"Site web computer far opens" will pass your spell checker (and maybe even some grammar checkers) but it doesn't make much if any sense in English. The compiler will pass anything that matches its set of rules whether it runs or not.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You could use .find() - see the examples at http://www.cplusplus.com/reference/string/string/find/ (there's an overload for a character to be matched)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I took entire courses on code tags and forum posting :) I'm not an IT Pro, but I play one on TV.

noparse is just another tag that says, don't translate any of the tags that are in between the noparse tags, so you can type something like "please use [noparse][code] code tags [/code] [/noparse]" It's a handy trick.

You can't post something with just a quote. Let the system do the work for you, as you can always experiment and edit your post afterwards.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

To post quotes as automatically expanded hit "Post Reply" and go to where it says "[QUOTE=happygeek;1408366]".

Just click where it says 'Click to Expand/Collapse' and the quote will, erm, expand or collapse.

Now delete the ";1408366" (or whatever the post number is)

Agapelove68 commented: Thank you jonsca for the specific instructions. I'll eventually catch on. I'm quick to attentiveness, but at times still lost here. :) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See this: http://www.bobpowell.net/faqmain.htm

Caveat is the examples are in C# and VB.NET, but the usual dot used for namespace in C# changes to C++ :: ,and dot used for member method in C# changes to -> (if the variable in question is a pointer) will apply. Look on MSDN to confirm the syntax if need be.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not very sure about stacks

You can certainly ask more questions. I was just giving you a general source. It's not something I would worry about for now, though.

'check for reaching the end of words'

If you are putting in a space when you type done it's all taken care of, but if you don't you should add one in within your program to make sure it will stop (otherwise it runs to the end of the array (1001) no matter how many characters you put in).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

At least attribute your source: http://www.wsdstaff.net/~dslade/c++WebPage/Ch08/Ch08_Examples/Ch08_Exmp5/MagicSquare.html

(your professor will appreciate it, too)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Skim through http://en.wikipedia.org/wiki/Call_stack (there's a lot of info there but it gives you an idea of where the terminology is coming from. If you try to access an index of an array that is greater than arraysize - 1, you run the risk of trying to access an address that belongs to an adjacent piece of data, which can corrupt the memory.

Like I had mentioned before, if you're having your user enter integers and they enter the letter a, it befuddles the input stream, the stream "fails" and stops taking any more data until you .clear() it.

Using .ignore() will allow you to take in a certain number of characters that the system will throw away. Sometimes when entering data, you get a stray '\n' (newline) in the buffer. If the next command is a cin.get() then the newline will be taken in and the program will effectively skip the pause in your program.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Rather, let your loop check for reaching the end of the words too, rather than '\0' as I said above, as that would halt it prematurely. Play around with the conditions of your for loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 46, the first portion of the for loop statement doesn't do anything, you could move part of line 42 into that position and have for(int StringPointer = 0;WordsToAnalyze[StringPointer] != ' ';++StringPointer) but that StringPointer variable will be destroyed after the loop completes since it's declared locally, so leave 42 right where it is and put for(;WordsToAnalyze[StringPointer] != ' ';++StringPointer) The primary problem is that there is no space after the word "done" so your loop keeps running. Let your condition account for reaching a '\0'.

You should also check in 46 whether you have hit 1000 characters, since if you have already done so, incrementing again will go to array position 1001 which doesn't exist and line 53 will cause an error.

You want cin.ignore(); instead of cin.clear(); . clear is for when you are reading into a stream and you've encountered something unexpected, which makes the stream go "bad."

.

Some random advice:
I have used the CPP Primer Plus in the past and really, really like it. The examples are crystal clear and well-explained. Someone pointed out something important about it, that it starts out as teaching you C and then working your way "up" to C++. This is considered by some to be an older method, not a bad one, but one that doesn't touch on the powerful aspects of C++ right away. I would suggest a book like "Accelerated C++" by Koenig and Moo because it takes such an approach. …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I can't directly answer your question, but there are programs available that do similar things like wix (http://wix.sourceforge.net). I've never used it (as usual), but it seems very extensible.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Iam using gcc compiler: gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5). And it allows me to use such things. Ok. i'll try now to use a constant.

Edit: tryed a constant - same sh**. Am, and have you noticed, that it is not the function which causes problems ? with this function everything is ok.

See my edit above. I don't want to speak for him, but I don't think that AD was saying this was the cause of the problem, but he was offering you some advice on your code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For line 140, you want is_open() for sure.

EDIT: Also, the g in seekg is for "get pointer," which belongs with ifstream only. The corresponding functions end in p for the ofstream. (see http://www.cplusplus.com/reference/iostream/ofstream/ midpage).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

inttobin is spelled incorrectly on line 25.

Remove line 72, the redeclaration of n is masking your function parameter n.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

One way to do it would be to go through your seating chart and use the price for each row to get a total.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
000000000111111111122222222223
      123456789012345678901234567890
Row  1
Row  2
Row  3
...
Row 10
Row 11

This way one seat number sits over one seat position and the rows are kept neatly in line.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i have everything fixed now except the allignment of the chart and "view seat sales" option which doesnt seem to work

I've told you how to handle the alignment in a prior post, and how is view seat sales supposed to work when there is just a stub there?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look at lines 131-133, there is no code there. If you are saying that is the functionality missing in your program, get these portions working first.

Put some cout statements in your program for debugging the freezing (or use a debugger). Try to isolate the line that it is freezing on (so putting in statements like "Checkpoint 3" or whatever you like after it's made so much progress). I can't reproduce the problem so I won't be much help.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
MAIN MENU
 1. View Seat Prices.
 2. Purchase a Ticket.
 3. View Available Seats.
 4. View Ticket Sales.
 5. Quit the program.
_____________________

Please enter your choice: 3


View Available Seats

        Seats
   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 30

Row 1 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 2 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 3 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 4 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 5 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 6 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 7 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 9 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 10 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 11 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 12 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 13 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 14 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 15 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


        MAIN MENU
 1. View Seat Prices.
 2. Purchase a Ticket.
 3. View Available Seats.
 4. View Ticket Sales.
 5. Quit the program.
_____________________

Please enter your choice: 2


Purchase a Ticket

Please select the row you would like to sit in: 4
Please select the seat you would like to sit in: 19
That ticket costs: 42
Confirm Purchase? Enter (1 = YES / 2 = NO)1
Your ticket purchase has been confirmed.
Would you like to look at another seat?(1 = YES / 2 = NO)1
Please select the row you would like to sit in:

I can't reproduce it unless I put in a letter instead of 1 or 2... Have you changed your code since the last time you posted it?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I compiled the code that you put up:

MAIN MENU
 1. View Seat Prices.
 2. Purchase a Ticket.
 3. View Available Seats.
 4. View Ticket Sales.
 5. Quit the program.
_____________________

Please enter your choice: 2


Purchase a Ticket

Please select the row you would like to sit in: 2
Please select the seat you would like to sit in: 5
That ticket costs: 30
Confirm Purchase? Enter (1 = YES / 2 = NO)1
Your ticket purchase has been confirmed.
Would you like to look at another seat?(1 = YES / 2 = NO)1
Please select the row you would like to sit in:

That's just one run, but I did try it repeatedly last night. What is the exact sequence that you used to get to that point?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The first is a preprocessor directive, before the compiler compiles your code, it will go through and replace sum with 1. The second declares a variable in memory to hold that quantity. I'm sure it can be argued as to which is best, but the "const int" is probably more common in C++ (when it comes to numeric constants).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster


123456789012345678901234567890
Row 1 ***###***###*########*****####
Row 2 ####****#####***************##
Row 3 **######*************#####**##
Row 4 **######**************##******
Row 5 ********#####********#########
Row 6 ###############*********######
Row 7 #######************###########
Row 8 ***************##****#########
Row 9 ##########*********#####******
Row 10 #****************#############
Row 11 #************#######********##
Row 12 #################*********###*
Row 13 ###************########**#####
Row 14 ##############################
Row 15 ##############################

okay so i wrote the code so far, its working except i have a few issues i have come across:

1. When select option 2 to purchase a ticket, it promps me for the row and seat number, but after that it asks "Would you like to look at another seat?(1 = YES / 2 = NO)" if i pick either option the program freaks out.

Doesn't happen if the user enters in a number, but if you hit a letter, yes, the stream goes bad and it loops. Either check if the stream fails using cin.fail() and loop back if the input is improper, or take the input in as a string and make sure it contains the integer, convert your string to integer, and carry on.

2. My second issue so far is that the seating chart is not aligned when asked to display (option 3)

This is going to take some finagling. I would stack your seat numbers on top of each other if they are 2 digits, like:
1 1
1 2
for 11 and 12, etc. Since some of your row numbers are more than 1 digit, you'll have to bump the first rows over a set number of spaces. Use an if condition in your printing loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

num1 only exists within the scope of main, you must pass it into your function to use it.

I have been reading your posts and I think that you are missing some fundamental ideas. If you have a textbook, go back and reread the appropriate sections, as your misperceptions are going to be harmful to your coding.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In the second listing, get rid of line 7 and wrap the code from 10 to 81 in

namespace SALES
{


}

You need to specify that all of that is in the same namespace as your header file declarations.

There's a bug with one of the array elements, but you should be able to find it now that you can compile and run it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You probably don't need system if it's a GUI application, as clicking the button to display hello world shouldn't close the window unless you explicitly tell it to.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you have support to MFC library then you can use CImage class. Its very easy to saving image as jpeg using CImage. Just pass handle to bitmap to CImage or load it from hard drive. Call Save function and specify jpeg as saving type.

True. There are also options available in .NET if you want to go on that adventure (since if you use the express editions, they don't have MFC)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which compiler are you using? They do have a makefile for VC++ version 10. If you have cygwin, etc. you can use the build instructions for *nix.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

As far as the second 3.14159 (with setprecision at 9), the mode is still the default one, so the extra zeros are not displayed (from the cplusplus.com site
"On the default floating-point notation, the precision field specifies the maximum number of meaningful digits to display in total counting both those before and those after the decimal point. Notice that it is not a minimum and therefore it does not pad the displayed number with trailing zeros if the number can be displayed with less digits than the precision." (http://www.cplusplus.com/reference/iostream/manipulators/setprecision/)

In terms of your request, what is your objective? (it seems to be changing from your original request) You could selectively format the number based on the digits after the decimal point, but that would get tedious. You are asking to have the default setting on some and the fixed setting on others. Perhaps if we knew what you were trying to accomplish...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Something like http://www.mpir.org/ (or http://gmplib.org/ if you're on *nix). Check the documentation for the largest number allowed, as 500! may far exceed it. Remember that 500! is a monstrous number! Check to make sure your assignment isn't to approximate it somehow.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to call your function for those values... Passing (0,0) to A gives ____ ?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just an aside, you shouldn't use .fail(), use .is_open()

.fail() is for checking when a stream reads something it wasn't supposed to (like trying to read a string into an integer).

There's one way to find out exactly where your program is failing, run it in a debugger and single step through your method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's a function carried through by the C standard library. See http://www.cplusplus.com/reference/clibrary/cstdio/printf/ but read the examples first instead of the theory.

I wasn't endorsing your use of it, especially if your class is in C++. My google search was for arguments in favor of one way or the other and I included the link for completeness.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You still don't set your vector elements to any values. Line 29 does absolutely nothing.

If you've initialized a vector, you can set the elements like x[index] = index (or any other value for that matter). Otherwise you need to use x.push_back(index) (or any other value).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

for(index = 0; index < score_length; index++); Something is amiss on that line. Check the end of it. Doing this causes the for loop to run score_length number of times with ";" as the line to be looped over.

You may want to pass the number of elements in the array into your function instead of size. Global variables are never a good idea.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look into the .push_back() method of the vector as well. Otherwise you are treating your vectors like arrays and they have so much more power than that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think what you're doing is correct, but:

Why dont you use 'printf ()'. This function is much handier, and lets you input everything you want (and print every way you want it).

This is probably one that could be argued either way. If the OP's class is using iostream, it's probably a good idea to stick with that.

Not to take this OT, but there are some interesting arguments about that here: http://stackoverflow.com/questions/2872543/printf-vs-cout-in-c