Wavelength and Axial Mode Calculation in C++
#include
// identifiers
voiddisplayMenu();
doublecalculateWavelength(double f, double c);
doublecalculateFirstAxialRoomMode(double c, double L);
doublecalculateLitresPer100Km(double mpg);
intmain()
{
// helper variables
int option;
double frequency, speed;
double length;
double mpg;
// star main program
while (true)
{
displayMenu();
std::cin>> option;
if (option >=1&& option <=4) // valid option
{
if (option ==1) // calculate wavelength
{
std::cout<<"Please enter the frequency (Hz): ";
std::cin>> frequency;
std::cout<<"Please enter the speed (m/s): ";
std::cin>> speed;
double w =calculateWavelength(frequency, speed);
std::cout<<"The wavelength is: "<< w <<" mts."<< std::endl;
}
elseif (option ==2) // calculate first axial room mode
{
std::cout<<"Please enter the speed of sound (m/s): ";
std::cin>> speed;
std::cout<<"Please enter the distance between boundary surfaces (mts): ";
std::cin>> length;
double f1 =calculateFirstAxialRoomMode(speed, length);
std::cout<<"The first axial mode frequency is: "<< f1 <<" Hz."<> mpg;
double lts_per_100km = calculateLitresPer100Km(mpg);
std::cout<<"The amount of "<< mpg <<" (m/g) equals to "<< lts_per_100km <<" (lts/100km)."<