Note that there are some explanatory texts on larger screens.

plurals
  1. POCode is not adding last defualt value
    text
    copied!<p>Im writing an application for my intro to programming class and the objective is to set up a simple program that prompts the user to enter a series of positive integer numbers between 50 and 100 (inclusive) using the keyboard. Your prompt should tell the user to enter a negative number to stop the input process.</p> <p>As the user enters the numbers, you should keep track of the number of valid entries they have made (those that fall in the allowed range), and add up those numbers entries. You do not need to store more than the single entered number, the count, and the current total you are calculating.</p> <p>Once the user completes the data entry, produce output similar to this:</p> <pre><code>A total of 5 values were entered. The sum of those numbers is 127 </code></pre> <p>make a program that will have one variable and it will retrieve the users </p> <p>Here is the code I wrote </p> <pre><code>#include &lt;cstdlib&gt; #include &lt;iostream&gt; using namespace std; int main(int argc, char *argv[]) { int loop = 1; int value; int times = 0; cout &lt;&lt; "Enter a negavtive number to quit" &lt;&lt; endl; cout &lt;&lt; "\nPlease Enter Any Number Between 50 - 100" &lt;&lt; endl; while (loop == 1) { cin &gt;&gt; value; times++; value += value; if(value &lt; 0) { cout &lt;&lt; "You entered " &lt;&lt; times - 1 &lt;&lt; " numbers" &lt;&lt; endl; cout &lt;&lt; "Total: " &lt;&lt; value &lt;&lt; endl; system("PUASE"); return EXIT_SUCCESS; }// end if statement } //end while loop system("PAUSE"); return EXIT_SUCCESS; } </code></pre> <p>Here is the output <a href="http://www.flickr.com/photos/62751645@N08/6286454476/" rel="nofollow">http://www.flickr.com/photos/62751645@N08/6286454476/</a></p> <p>I think it may have something to do with the fact that I am using the int value to do two different tasks. How might I go about fixing this?</p> <h1>revision</h1> <p>thanks to all of you for the "fix" I add a new variable and it works like a charm, but now the math is not adding correctly <a href="http://www.flickr.com/photos/62751645@N08/6286526294/in/photostream" rel="nofollow">http://www.flickr.com/photos/62751645@N08/6286526294/in/photostream</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload