working on Drills from chapter 4 of Programming: Principles and Practice using C++. Bjarne Stroustrup
<p>I've been bashing my head against these drills for days and I can't grasp them.
I have to add a unit to my numbers (i.e m,ft,in,cm.) and reject invalid units, then convert the numbers and units into metres.<br>
I have my code that shows how to choose and keep the highest and lowest numbers etc, but i'm at a complete loss as to how to add the unit part, i've tried if statements and they seem to look like they'll work, but then they don't and i get frustrated and it honestly bugs me that i've missed some fundamental point.
here is my code so far</p>

<pre><code>int main(){
double val1=0;
string unit;
double large=0;
double small=0;

cout&lt;&lt;"please Enter 1 number and a unit (cm, M, Ft, In):\n";
while (cin&gt;&gt;val1&gt;&gt;unit){

    if(val1&lt;small) {small=val1; cout&lt;&lt;"smallest so far\n";}//find smallest number
    else if(val1&gt;large) {large=val1; cout&lt;&lt;"largest so far\n";}//Find largest    number



else cout&lt;&lt;"Neither largest nor smallest\n";
}
cout&lt;&lt;"The smaller value so far is (in metres): "&lt;&lt;small&lt;&lt;"\n";
cout&lt;&lt;"The larger value so far is (in metres): "&lt;&lt;large&lt;&lt;"\n";

keep_window_open("~");
return 0;
</code></pre>

<p>}  </p>

<p>It's not homework and I'm only doing this for my own interest. any help would be appreciated.</p>
