//OrinTill Qimid CS1A Chapter 4, P. 224, 19
//
/**************************************************************
 * compute speed of sound
 * 
 * ____________________________________________________________
 * This program will claculate how far away the source of the sound is coming from.
 * ____________________________________________________________
 * INPUT
 * choice : the choice of medium.
 * sound  : the given time.
 * OUTPUT
 * air : distance of sound travel through the air.
 * carbon : distance of sound travel through carbon dioxide.
 * helium : the distance of sound travel through helium.
 * hydrogen : the distance of sound travel through hydrogen.
 * The manual output that shows the choices.
 **************************************************************/
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() 
{
    float sound,
    carbon,
    air,
    helium,
    hydrogen;
    int choice;
    cout<<"---------------------------------------------"<<endl;
    cout<<" Medium              Speed(Meters per seconds)"<<endl;
    cout<<"---------------------------------------------"<<endl;
    cout<<"1.Carbon Dioxide       258.0"<<endl;
    cout<<"2.Air                  331.5"<<endl;
    cout<<"3.Helium               972.0"<<endl;
    cout<<"4.Hydrogen             1,260.0"<<endl;
    cout<<"---------------------------------------------"<<endl;
    cout<<"please pick a number from 1 to 4 for your medium and enter how long it too for the sound to reach your destination";
    cin>> choice;
    if (choice<1)
    {
       cout<<"thats not a vaild input"<<endl;
    }
    else if (choice>4)
    {
       cout<<"thats not a vaild input"<<endl;
    }
    cin>> sound;
    if (choice==1)
    {
        carbon = sound *258.0;
        cout<<"The souce of the sound is coming from "<<carbon<<" meters away";
    }
    else if (choice==2)
    {
        air = sound * 331.5;
        cout<<"The souce of the sound is coming from "<<air<<" meters away";
    }
    else if (choice==3)
    {
        helium = sound * 972.0;
        cout<<"The souce of the sound is coming from "<<helium<<" meters away";
    }
    else 
    {
        hydrogen = sound * 1260.0;
        cout<<"The souce of the sound is coming from "<<hydrogen<<" meters away";
    }
    
    return 0;
}