I am stuck on how to calculate percentages for the total number contributed by each different size of pizza. My book doesn't have any examples of using division to solve. I tried to use sum but I keep getting errors. Here is my attempt at it using microsoft visual studio 2012. I also get an error LNK1168: cannot open everytime I try to debug again. Any help would be greatly appreciated!
but division by 0 just gives #inf whatever it is value when you print it and does not prevent running code unless you set some sort of flag to make it error out.
I agree that you want to compute the total first, that is a bug, but it should actually run, right?
thanks for responding, the program runs and collects the total but that is it. I don't get an #inf error in the debug. Is there any site that could help me with this?
The problem is that you're computing totalPizzasSold at line 33, but you're using it before that, at lines 29-32. At lines 29-32, totalPizzasSold still contains the value that you assigned at line 10.
ah, ok if it runs that makes sense. #inf isnt an error. Its a "special" value of floating point that print statements can handle that tell you when you goof up your math by doing things like dividing by zero. It literally prints some text with the letters inf (infinity) in it, or it should.
That aside, all you have to do is total before you divide. That is it. You are very close, move that one line of code before the divisions.