jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just start j off at i+1. That way you're comparing 0 with all the rest, 1 with from 2 onwards, etc., etc.
If you need to keep track of whether or not you find a birthday more than twice keep the values in an array and check your new entry versus what you already have.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I imagine if you followed the if block of the do/while you could get all of the directories and just save the names instead of totaling the file sizes

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

main should always return an int, not be void.
You need to make x and y reference variables, otherwise you're passing them in and they are changed but this is not reflected in the original variables. void A(Complex a,double & x,double & y)

sleepybug commented: yup..the reference thing worked.;) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out AD's code snippet it's about file sizes but the code to traverse the directories should be along the lines of what you want. All else fails, google it again.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

if (inputStrings[i].Substring(0, 2) == "###") Take a look at the definition of substring and you'll see why this is impossible. I missed it before...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I made the following changes to the TriviaQuestion class, see if substituting this one in helps:

public class TriviaQuestion
    {
        private string question;
        private string answerA;
        private string answerB;
        private string answerC;
        private string answerD;
        private string correctAnswer;

         //properties
        public string Question { get { return question; } set { question = value; } }
        public string AnswerA { get { return answerA; } set { answerA = value; } }
        public string AnswerB { get { return answerB; } set { answerB = value; } }
        public string AnswerC { get { return answerC; } set { answerC = value; } }
        public string AnswerD { get { return answerD; } set { answerD = value; } }
        public string CorrectAnswer { get { return correctAnswer; } set { correctAnswer = value; } }
 //explicitly tell it to get and set the private member variables
    }

You have it trying to pull data out of answerA, etc. when all your getters and setters (the default ones) are capable of is getting and setting the properties like AnswerA, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm in the process of recreating your form.
Are answerA thru D radio buttons?
What is wrongNotif?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have you run it through the debugger?** That will be able to tell you exactly where you lost the data. Otherwise I'll take a closer look.

I'd make a private method for lines 24-31 (Quizform) and call it in the load method and in nextbtn_click.

In Triviagame from lines 33-44. What I would do is read the values into a temp, check if it's got # as the first character, if it does take the substring from 3 to the end and put that into the correct answer slot and where it belongs (a,b,c,d). Just a suggestion. That way you don't have to loop twice.

**if you hate the debugger, which you shouldn't :) but if so pepper your code with System.Diagnostics.Debug.WriteLine() statements and it will show up in the output window of the IDE (or output them to a temporary textbox on your form itself)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Add 1.0/1.0+1.0/2.0+... when you do integer division (e.g., 1/2) regardless of the variable the result is going into it still still gets truncated. If you haven't already make sure your result is declared as type double otherwise nothing will work.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out the third post of this thread. It may hold a solution for you.
I tried the ios_base::in | ios_base::out | ios_base::app approach and the compiler did not complain but it does not seem to work either (which is what is discussed for the rest of that thread -- but I don't know if it still works on the Microsoft compilers today as they were speaking of VC++ 6).
So basically the thread was suggesting if it doesn't open, open one with out only, close that one and reopen it (presumably you can open for in and out at that point).
Hope this is what you were looking for -- there may be a more straightforward solution but I don't know one offhand.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you post more of your class and perhaps a few lines of your text file?
It's not readily apparent (at least not to me anyway) what the problem is from the bit you posted.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is a good site overall to get this kind of information:
http://www.cplusplus.com/reference/string/string/

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out this thread. It's not exactly what you want but it gives some good ideas of how to roll your own.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure who the founder is but she's associated with it (and written the tutorials) for sure. I was being informal.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Place it inside of main()

int main()
{
   srand( time(0) );

A seed is a starting point in the internal sequence for a pseudo-random number generator. Giving the same seed twice would result in the same sequence of numbers.

For more info, check out the tutorial on Narue's website. It's infinitely more comprehensive than anything I could come up with off the top of my head here.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you allowed to pass anything into ReadQuestion? somehow you have to send the streamreader object in so it can maintain the position in the file each time.

Also, there's no way to access the private question variable in the TriviaQuestion class.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Oh ok. I meant to change it in the other two places but not in the function call itself. Take out the brackets on line 55 and just call it with students like you did before.

There's some work to be done in the function definition. You need to come up with a name for your parameter that is of type theStudent and use that in the function instead of just theStudent. You also can't test for equality between a struct and a value.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you post up the search function too so I can give it a try?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It probably means you should move your prototype after your struct (probably the best idea) or you can forward declare your struct (put "struct theStudent;" before your prototype and leave the struct declaration in place).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your first argument in the search function should be prototyped as theStudent [] instead of int [] (and probably needs to be changed in your function definition as well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For your ratio try 364.0/365.0, you probably keep getting 0 for 364/365 since it's still considered integer division.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Got it, I think.

See if this is what you need. I left the System:: etc. qualifiers on there just to make sure it wasn't getting the wrong classes. I'm pretty sure everything you need is there, but if need be I can upload the project.

valeriy_zf commented: Good job, Thank you! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

string.str(a) So you're still not doing anything with that statement. You have almost everything you need, but treat your string like an array a[0] is the first character a[a.length() - 1] is the last.

Also, how are your results getting back to main? Look up what it means to pass something by reference. You have it the right way in your method, just not in main.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah, I've got to puzzle over it some more. I think we've got it there's just a simple scope issue that I'm running into.

Well, you could break up the drawing procedures again and give the form access to them (might be easier). Anyway, best of luck with it. Apologies that I couldn't help more.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just looking over your code again, I'm realizing that you are trying to make a form within your Test1 class. I would make it separate and have it include your Form1.h as a header and use the namespace from your Form1.h file (and your project overall).

#include "Form1.h"
using namespace FormControlinClass;

Then include your Test1.h file in your form1.h file (there's a way to take care of all of this with stdafx.h but I'm not up on it enough).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm having difficulty with it after I tried it out. I will figure it out. Part of the problem (unrelated to the one that we are having now) is that the button is declared as private within the Form1 class. In order to access it it needs to be public.

EDIT: What you have up there is not correct. You should be instantiating Test1 in the form header, not making a new form1 there. You don't need to start another form in form1 you have one. Test1 ^ mytest1 = gcnew Test1(this); pass in the pointer for the form from the form class.
Then in the click method put mytest1->ChangeButtonText();

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This would be the constructor for the same class that contains your Change_Button_Text() -- sorry I missed the underscores when I wrote it out. So when you instantiate Test1 in form1.h you just pass in "this" to the constructor. Make sure you put the new prototype for the constructor in your header as well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Rather than instantiating a new fr1 within your class, let the constructor of Test take your form as an argument:

In the declaration in the header:
private: Form1 ^ frm1inclass;
In the cpp file:
Test1::Test1(Form1^ form1)
{
     this->frm1inclass = form1;
}

void Test1::ChangeButtonText()
{
        frm1inclass->button1->Text = "Whatever here";
}

I didn't try compiling it so there may be some missed "punctuation" but you get the idea.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Super! I was going to suggest that at one point but I thought it was redundant. Oh well. Glad it worked out.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You got me. It did seem like people were having problems sending from gmail. I only sent to gmail not from it.

By other settings I mean the members of SmtpClient.

I'm afraid I don't know much more than this about these types of systems.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure what the problem is... I sent via ISP's SMTP server to gmail and it worked. A couple of possibilities I ran across:
Try changing client->Port to 587.
-or-
Make sure you're running as admin so that you have the right privileges to send email.

There may be a few other settings you can play with. You could try asking your ISP/server admin for details...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try substituting these in for line 8. You were trying to pass it into client as static which might work but this way you get all the proper info in there. I tested it, it works.

CredentialCache ^ mycreds = gcnew CredentialCache();
	mycreds->DefaultNetworkCredentials->UserName = "bob";
	mycreds->DefaultNetworkCredentials->Password = "bob";
	
	client->Credentials = mycreds;
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

str() is a method used with stringstreams to get the string portion. It doesn't seem like you need stringstreams or str() here.

Remember that you can access strings as an array, so string[0] is the first character of the string. string.str(s) <= s doesn't make any sense. You were on to something when you were talking about the length() method. So you know how long the string is once you've read it in.

If you are calling your method in main, you need to pass in all of the parameters including the reference ones.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You get where the click came from via the e parameter. e->X gives you the x coordinate and e->Y the y. It's going to be tricky to get your user to grab the exact point I think, you may want to use a (small) range.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is a frustrating thing to deal with. I looked at it as such:
Make a class that holds your data points in a list and has a member method Draw, drawing each point up until time.

void Points::Draw(Graphics^ g , int time)
	{				
			Pen ^ mypen = gcnew Pen(Color::Black);
		for(int i = 0;i<time;i++)
			g->DrawRectangle(mypen,listpts[i].X,listpts[i].Y,1,1);
	}

In form1.h have 2 event handlers

private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
				 pts->Draw(e->Graphics,time);
				 time++;
				 
				 }
	private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
				 Invalidate();
				 }

Use an interval on the timer of 1000 and start it in the Form1 constructor. Each time the timer ticks (1 sec) it will paint all of the dots up until that time. I'm sure there's a better way to do it but there may be no escaping the need to repaint all of them on each new dot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, you'll see later that if you want to use your object with cout you have to "overload" the << operator. If you don't have that in place and try to output an object (which is effectively what you did) the compiler panics. I'm still not sure why it does it 80 times but I'm sure there's a reason.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
int numbers[] = {10,20,30,50,70};
	float mean = AveArray(numbers,5);
	std::cout <<mean<<std::endl;
	float stddev = StandardDev(numbers,5,mean);
	std::cout <<stddev<<std::endl;
36
24.0832

Checks out on Windows Calc

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you try testing your methods with a 4-5 element array like VernonDozier had indicated? Try that first. I know it may seem like a pain to break your code down (just copy and paste relevant portions over) but it will save you a lot of time in the long run.

Then, failing that, are the numbers huge and/or way out of proportion? In that case something may not have been initialized properly.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look into the finally {} block too. I regret that I don't have much expertise in this area.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's your first h matrix that's fouling things up. You are catching the exception of the first try, but then in the second one you're allocating the memory for it anyway. You end up creating a bunch of rows of 0 columns (that perhaps fail silently?) and so when you go to delete something that never existed you get the exception. That may not be exactly the case but it's something along those lines.
Exceptions in constructors are tricky and there's a lot written about them. I'm not sure exactly what you need but probably skipping that second try block when the first fails would work.
Your second h matrix clears fine, as it has it's own scope within the braces so it evaporates after that closing brace.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can post back what you have but I think you're probably so close to it that you'll find it without a problem.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For which setting? What you are looking for might be under Build.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In your AveArray method:

float AveArray(int Numbers[], int Total)
{
	// Declared Variables
	int sum = 0;      //INT 
	
	// Just to make sure there isn't any junk values.
	float Mean = 0,0;
	
	for (int i = 0; i < Total; ++i)
		{
			sum += Numbers[i];  //INT
		}
		
	
	Mean = sum/Total;   // = INT/INT   **
                      
	return Mean;
}

** the result of integer by integer division is another integer (so truncated or 0 if numerator <denominator) which is then assigned to the float value.

Instead, cast one or both integers to a float: Mean = (float)sum/Total; or Mean = (float)sum/(float)Total; You're going to run into a similar problem with sum2 in the next one where you're trying to cram down the result of pow into your int. Making sum2 a float will make that situation better and it will ensure that you don't have the same truncation problems in that method too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In the + operator code, change

return matrix (*this) += in;

-to-

*this += in;
return *this;

It seems to work...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Disregard the above, I didn't see that you were trying to do that on purpose further down in main().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

S= standard deviation = square root of (sum/N)

FWIW, and I don't think it affects it too much for OP's purposes, it should be N-1 instead of N since it's a sample from a population (unless you have enough data to justify a population). Not knowing the population gives you one less degree of freedom.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I didn't immediately find the solution to the problem but part of the problem is in the += operator, it keeps saying your matrices are different sizes and returning *this.

if ((column!=in.getColumns())||(row!=in.getRows()))
{
	cout <<this->getRows()<<" "<<this->getColumns()<<endl;
	cout <<in.getRows()<<" "<<in.getColumns()<<endl;
	throw invalid_argument ("Matricies must be of equal size.");
}

I get 3 4 for a which is presumably correct but 5 5 for b which is not.

Just wanted to give you a lead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You forgot the car:: on the last three methods.

What you want to be returning with the getDoors() is carsDoors. The names of the private variables must match up exactly. The reason you have some leeway with the method parameters is that the names are essentially local to that method. Think of your methods as being a go between for the private members and the outside world.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Make it so that your if statement looks for the vowels, then have else if look for the consonants (hint: all the vowels will be filtered out by the first stage so you don't have to be so fussy about the ranges), then have else determine not-a-letter status.

if (get the vowels)

else if (get the consonants)

else ( not a letters automatically here)

Draw it out on paper if you are still having trouble.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do your applications use either the MFC (MS Foundation Classes) or the ATL (active template library)? Those libraries are only found in the Standard Edition and higher. Otherwise VC++ Express only supports pure Win32 and Winforms for C++/CLI.

I'm not absolutely sure what in terms of the actual C++ standard was implemented from version to version. I know there's a listing of things that are still non-standard for each generation (they don't have one for 6.0 any more but here's the one for 2008 (you can get them for as far back as 2003 edition on the right side of that window).