jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was able to read "COMPLETE" through the following:

string fileline;
     HttpWebRequest reqFP = 
      (HttpWebRequest) HttpWebRequest.Create("http://jamesgeddes.com/wttr.txt");
     HttpWebResponse rspFP =  (HttpWebResponse)reqFP.GetResponse();
     Stream st = rspFP.GetResponseStream();
     using (StreamReader sr = new StreamReader(st))
     {
           fileline = sr.ReadLine();
     }
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have a series of if/else if statements where those variables are assigned with no else statement at the end. What happens if the system goes through those choices and your value doesn't fit any of the criteria -- the variable goes unassigned. So either make your last else if in the series into an else (which will catch anything that doesn't match) or come up with something to put into the variable in the else statment. So for example:

if (numpay == 1)
{
   numpayadd = 0.02 * cc;
}
else if (numpay == 2)
{
   numpayadd = 0.06 * cc;
}
    [COLOR="Green"]else [/COLOR]
{
   numpayadd = cc * 0.08;
}

or

if (numpay == 1)
{
    numpayadd = 0.02 * cc;
}
else if (numpay == 2)
{
    numpayadd = 0.06 * cc;
}
else if (numpay == 3)
{
    numpayadd = cc * 0.08;
}
[b]else
{
      numpayadd = -999;
} [/b]

The only problem with the second one is you'd have to check for that error in subsequent calculations.

Also, please learn to use code tags:

[code]

//code goes here

[/code]
as they maintain the spacing so code is a lot easier to read. Also, for next time try to pare down your code a bit so that people can find what they are looking for.

ddanbe commented: Bravo, for reading 2500 lines of code! +6
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

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

So lines 48 and 50 are still wrong. Strings do not have single quotes. I'm not sure what more I can tell ya.

totalwar235 commented: worked perfectly +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I first ran into Adatapost in the C# section. He was a fairly prominent figure there when I first started (all those long months ago!!) and still keeps up his posts as a mod. I think he's patient and kind to the extreme and truly enjoys helping people learn. He's also encouraging with rep and nice comments!

P.S. Just like with vegaseat, I have yet to figure out what an adatapost is. Is that like a sign post for data to follow? ;)

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

That finally ends countless hours of idle speculation on my part. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Vegaseat

So is it truly "Vegas Seat" or "[Chevy] Vega Seat" or "[star] Vega Seat" or "Vegas Eat"? There are a few others but I don't know him well enough to write them...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Give me a tutorial

This is very demanding and bordering on rude.

Despite that I (more than wholeheartedly) agree with WaltP's sentiment I still wanted to plug a book that I really liked which was this. It's also legitimately free which is nice.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Wow. I'm speechless and totally honored. I'll have to return the favor:

Nick Evan:
Well what can I say a great moderator and a great guy( when he's not running over elderly men on their bikes off the road for the sake of a good story).

When I first got here I thought he was a moderator because he kept a level head and kept discussions on track (he officially became one soon after that). Like all of the great mods here he offered excellent advice too! He has too many posts to count (well over 3k) and has (according to the rollover label) "a reputation beyond repute."

One thing I don't know is how to pronounce his screen name. I tend to pronounce it like Nicky, but I suppose it could rhyme with "sneaky" or sound like "Nikkei."

Well, there's so much more I could say but I'm sure there will be many others who will sing his praises.

(as a response to one of his comments: I'm very deliberate about my bad post reporting, I know. I also figure that the top secret moderator forum must get pretty boring so I do like to provide a little entertainment with my reports--occasionally it trickles out into my non-Geeks' Lounge posts as well)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

have a program that pops up and has buttons to run different code i made

Unless you've got some GUI experience in another language that's going to be a bit of a road...give it time.

i want to make it so its kind of a game where i have the questions and depending on the score at the end they either have to redo the questions or go to a new set...

That's going to take some strings knowledge. Grab some tutorials. Start simple. Look into arrays to store your questions. Look into files to store additional sets of questions.

correct == >3
correct ==<3

See if you can figure out what's wrong with those two statements.

Agni commented: You've got patience, you can make an excellent teacher :) .. +3
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Oops, didn't think about putting that after the comma. I'm on a roll today.

WaltP commented: Hey, sometimes it's better to just go to bed :D +9
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

True story from IIT Bombay

http://www.snopes.com/college/exam/flattire.asp .. and everywhere else.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

169 C:\Users\...\sequence.cpp 'class Sequence' has no member named 'conacatenate'

There may be other things wrong but did you read this error message carefully? You have a typo in there somewhere. Sequence s3 = s1.conacatenate(s2); Right there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Anything that's private, forget about using the dot operator with it at all. You're closer:

string carsmake;

	cout << " Please enter Make of car: ";
	cin >> carsmake;  //taking into your temporary
                              // (this presumes a one word car make btw)
	cars.setMake(carsmake); //passes in through your method,
                                 //compiler is happy
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry, it was a stringstream ss; so include <sstream>

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't have to do any casting. Go element by element. If it's '1' (ASCII 49) how would you recover 1 from 49? How would you recover 2 from 50? Subtract 48, which is '0'.

char a = '4';
int x = a - '0'; // since chars are really ints
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you are writing a C++ program why are you only using the C libraries?

See this about gets(). It may not solve all the problems with your code but it will be a step in the right direction. Use something like fgets for all your char array inputs.

Nick Evan commented: Moved to C +12
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Or attempt a design where it is created in main() and passed into the functions that require it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

#include <ctime> and call srand((unsigned)time(0)); (once) before you call rand().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't have to, just giving you the proper credit and verifying that I didn't lie there in wait for you to post and immediately copy what you said. Or it's a bad habit I picked up. Your choice :D

WaltP commented: I'll take it as a bad habit :-) +9
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You shouldn't repeat all those calculations over and over in each branch of the if statements.
Do the common calculations, have an if statement that changes any values that are uncommon to the set, then proceed with the next set of common calculations for the group, etc.

Also, you should pass in arrays, structs, or vectors of your parameters to your gauss function to clean up the sheer volume of values. It's just a lot to have to put in there and once you get beyond 4-5 parameters it starts to make your head spin.

Other than that, seems to be ok but I didn't put it under a microscope. Keep plugging away at those numerical methods! :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Part of the problem is you are trying to read a text file in binary mode. In binary mode you need to use read() to get a block of bytes. I can see how it might read some of the chars in that way but there must be some subtlety that is goofing it up. I would omit the ios::binary and see if that improves things.

Also, why are you trying to read 257 characters into the 256 char array? (that would be valid if you had indexes 0 through 256 but you only have up to 255)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
stringstream ss;
ss <<"Hello"; //send this into the stringstream
cout << ss;    //gives the address of ss
cout <<ss.str();  //gives "Hello"
string mystr = ss.str();
then mystr.c_str() is "Hello\0"

so with ss.str().c_str() we're first taking the stringstream object and using it's str() method to access the string, which we're then calling the c_str() method of that string to get the null terminated one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Start out with something like this (it has good examples for you). Google any terms you don't know and when you have something you're stuck on, post back.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

or system("clear"); on *nix computers.

system is used to run a command of either dos or *nix on the respective system. He was offering you system("cls") on your Windows baed PC or system("clear") for use in *nix if it was applicable.

However, AD was also saying that this information is not even relevant to your task at hand because this is simply a solution to wipe the console clean of any output and it does nothing to any of your inputs that you are asking how to clear.

Salem was simply saying that we really don't know what you are trying to do so we cannot help without more specifics. If all you want is a keypress to keep something going just throw away the key or never save it in the first place a la getchar() with no lvalue.

(sorry to speak for anyone if they didn't intend it like that)

Ancient Dragon commented: Exactly right :) +26
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you try branching off from your 3 of a kind method?

bool FullHouse;
if (Hand.Card[4].iValue == Hand.Card[3].iValue && Hand.Card[4].iValue == Hand.Card[2].iValue)
{    
      if(Hand.Card[1].iValue == Hand.Card[5].iValue)
             FullHouse = true;
      else
      ThreeOfAKindCard = Hand.Card[4];
}
else if (...) etc.

I know it doesn't combine your pairs check with the three of a kind but if you don't "sequester" the three of a kind cards they'd be counted by the pair finder too. A solution would be to have a pair finding function that you could call both for both finding the pairs and finding the full house.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, what do you consider to be the essential features of OOP? One hint: what kind of inheritance does C++ support vs. Java. I didn't do a net search but I'm willing to bet if you google this you'll come up with tons of "ammunition." Keep in mind that each language's implementation has it's pluses and minuses and more is not always better.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Being adroit in Detroit is so gauche!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I believe it's a known problem. I don't have a solution offhand but unless you are needing 6.0 for MFC or ATL work then you should probably grab the 2008 express edition (http://www.microsoft.com/express/Downloads/#2008-Visual-CPP) it does console programs, Win32, and Winforms via C++/CLI.

Ancient Dragon commented: Good advice. +26
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Start a new project in VC++ this time uncheck precompiled headers and leave empty project unchecked. Add your files to the project by right clicking on the solution/Add.. etc. and you can clear out all the other files (or just exclude them from the project to be safe). You've probably done everything correctly except for the precompiled headers part.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And some of us hate baseball.

Hey, nobody's perfect. :D

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's even more gauche to pronounce it "Gow-chee." That's just plain meta-gauche.

mrnutty commented: Touche` +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't overbook it, don't provide the "scratchy towels" (a la Verizon ad) and make sure it remains an "ool."

On a more serious note, what ideas have you had thusfar? It's going to be quite similar to any kind of hospital management in terms of having people as an object, or library management program where the objects are books. There are lots of examples of these types here on the site that you can draw ideas from.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have to cast either the numerator or the denominator (or both) to a double otherwise it does the integer arithmetic first and stores it in the double. double average=((double)(sum+999))/(count-1); I put some extra parens on there just to be sure.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes. Though it doesn't mean you can ferret all the files away on your harddisk somewhere and they'll automatically compile or anything. Namespaces still need to end up being part of a particular assembly (search ".NET assemblies" for more info) to make sense.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Think of it as an extra layer of misdirection :)

If you code in any kind of organization (or even if you don't), you will inevitably have 180 different Print methods in different classes, some of which will be named Output (just for sake of argument).

Now say 16 divisions got together on a project and pooled all their class resources together into one megaproject. People would be trying to call Print() and getting all kinds of results. You can encase your classes in a namespace (not completely unlike encasing your methods in a class) and be able to tell them apart.

So you can have the output class of production be Production.Output and the Print method be accessed as Production.Output.Print(). If someone wants to use a particular method they can call it by it's fully qualified name. If you know that you're just using the class or method within your own division, you can put a using Production.Output; at the top of your code (conventionally, I suppose it can be anywhere before you call the method, but I may be incorrect about that).

As to your specific question, you can and will have a namespace that crosses multiple files. For instance when you create a winforms application you get a Form1.cs, Program.cs, the design files, etc. that all share a common namespace by default. It's not necessarily a collection of files but for example a certain subset of a dll's classes …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also, see this post and for an article with lots of examples, see this.

(sorry adatapost, I was already in process when you posted)

kvprajapati commented: You are always helpful +6
chaienbungbu commented: Thanks. After reading your example, I remember that my problem related to "passing by ref". +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
private void button1_Click(object sender, EventArgs e)
        {

            //http://dotnetperls.com/filename-datetime
            
            string fName = string.Format("myfile-{0:yyyy-MM-dd_hh-mm-ss-tt}.txt",
            DateTime.Now);

            using (StreamWriter sw = new StreamWriter(fName))
            {
               sw.WriteLine(textBox1.Text);
               sw.Close();

            }
        }

I found the way to get the formatting into one that is acceptable to file names on that site in the comments. Otherwise you can probably play around with the ordering of the time-date information.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hate to be a "Me too" but me too just now. I had also experienced the 15 second message Salem got a few days ago. I'm going to lie awake tonight staring at the ceiling wondering why me. :D

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Something like this will work http://pdcurses.sourceforge.net/ (the header alone won't do you any good without the libraries anyway)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

you have to mention its return type "void" or "int".

void main is actually incorrect (though your compiler may take it)
See this article.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need to put the return type of the function before its name when you are calling it (definitely need it in the prototype and in the definition though) reverse(s,i); is all you need on that line you have marked.

Also, you should put int in front of main (your compiler might be doing it implicitly but don't rely on that)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

rand() % 7 is going to get you numbers between 0 and 6 which will overstep the bounds of your array by 1 if a 6 is pulled.

I'm confused why you broke up the loop like you did?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not for the console app (which is the best setup for programs like you had initially), but for the Win32 program setup that's exactly the type of thing you need. Console app has a main() function.
There are arguments either way but it's usually easier to get the language down pat with the console stuff first...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Select Win32 Console App (and while at that uncheck use precompiled headers and leave empty project unchecked). That should get you started with it. I don't know if you can change it after it's been created, just start a new one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Woh, thanks you have been extremely helpful

Hey, no problem at all. Definitely post back with further questions on this.

Are you talking about making a program in a window instead of the console? You'll probably want to polish your basics a bit but look at http://www.winprog.org/tutorial/ for Win32 (MS has other window frameworks but Win32 is the most fundamental). There are other toolkits like Qt and wxWidgets that can be used with other compilers.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you're wanting to learn something directly applicable, read about switches. It's almost like a shortcut to writing systems of nested if else statements. Check out:http://www.fredosaurus.com/notes-cpp/statements/switch.html
I suggested the arrays because it would be nice to store your usernames in one array and passwords in another so you can compare usernames to passwords easily.
I suggested functions because it might be nice to have a function to govern the login so that you're not dealing with the password verification stuff in the main function.
Neither of the two things above is really required, though.
So you're really free to do however much you want with it. If it is one of your first few projects, keep it reasonably simple. Also, it helps to make a piece of it first, test that out then add another piece.