Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here are the suggestions for your program: <br><br> 1. Use something like <code>system("pause");</code> to pause the program or make change in project settings if you are using Visual Studio so that debug windows waits for you after execution.<br><br> 2. For next <code>if</code> statements you should use else statement and surround by braces. Here's an example,</p> <pre><code>else if (unit == 'p') { if (amount == 1) std::cout &lt;&lt; amount &lt;&lt; " pound is $" &lt;&lt; amount * pound_per_dollar &lt;&lt; " dollars.\n"; else std::cout &lt;&lt; amount &lt;&lt; " pounds is $" &lt;&lt; amount * pound_per_dollar &lt;&lt; " dollars.\n"; } </code></pre> <p>If you do it in this way your last <code>else</code> statement will give you correct result. Otherwise you'll always get "Sorry, that input isn't in the correct format" except for 'e'. Indeed, that's what happening in your program.<br><br> 3. You should do add a <code>return 0</code> statement for your <code>int</code> return type of <code>main</code> function.<br><br> 4. Instead of typing std every time you can add this statement once,</p> <pre><code>using namespace std; </code></pre> <p>after your include preprocessors and may omit including <code>std namespace</code> afterwards like this,</p> <pre><code>cout &lt;&lt; "Please enter a amount followed by a unit (p, y, or e): "; </code></pre> <p><br>5. e is a reserved char for using with integer/double etc numeric types. e means exponential. When entering currency, use a space before to explicitly tell cin that this e is not part of numerical input. Otherwise, you have to parse the input using strings.</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