Connect with a global community of knowledgeable individuals on IDNLearn.com. Our experts are ready to provide in-depth answers and practical solutions to any questions you may have.
Driving is expensive. Write a program with two inputs, a car's miles/gallon and the cost of gas/gallon both represented as double variables, and output the total drive cost for 10 miles, 50 miles, and 400 miles, all on the same line, each separated by a single space.
Output each floating-point value with two digits after the decimal point, which can be achieved by executing the command
cout << fixed << setprecision(2); once before all other cout statements. That is done only once in the code before any cout stamtent.
Ps:(when i run the program it says this-
Enter miles per Gallon:
Gas cost for ten miles :-nan
Gas cost for fifty miles :-nan
Gas cost for four hundred miles:-nan
Thank you for using this platform to share and learn. Don't hesitate to keep asking and answering. We value every contribution you make. IDNLearn.com provides the best answers to your questions. Thank you for visiting, and come back soon for more helpful information.