Please help, I can't get more than 5 decimal places in my answers and I don't know how to tweak the code to allow for this. Any help would be greatly appreciated. DB

#include <iostream>


using namespace std;

int main()
{
system("title You can Convert Miles to Kilometers or Convert Gallons to Liters");
system("color 17");

long double mile;
long double gallon;
char choice;
for (;;){
do {
cout<<"Welcome to my special conversion program.\n";
cout<<"\n";
cout<<"Please choose one from the following menu and press enter.\n";
cout<<"\n";
cout<<"************************************************\n";
cout<<"Exit Program\t\t\t Enter q\n";
cout<<"Convert Miles to Kilometers\t Enter 1\n";
cout<<"Convert Gallons to Liters\t Enter 2\n";
cout<<"************************************************\n";
cin>>choice;
} while ( choice < '1' || choice > '2' && choice != 'q');
if (choice == 'q') break;
switch (choice) {
case '1':
cout<<"Please enter how many MILES you want to convert to KILOMETERS\n";
cin>>mile;
cout<<"\n";
cout<<"Your total kilometers are\t"<< mile * 1.609344;
cout<<"\n";
cout<<"\n";
break;
case '2':
cout<<"Please enter how many GALLONS you want to convert to LITERS\n";
cin>>gallon;
cout<<"\n";
cout<<"Your total liters are\t"<< gallon * 3.78541178;
cout<<"\n";
cout<<"\n";
break;

}

}
return 0;


}

try using...

#include <iomanip>

cout.setf(ios::fixed, ios::floatfield);
cout.precision(8); // sets number of decimal places

Wow, you are awesome, thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.