1. Plan your logic before working on the project and review the syntax you will use in the project. Think about how you want the lines of output to be displayed to the user. You will want to tell the user what the program does and what type of input you expect from the user (Introduction to the User). Select names of the variables you will use in the program.
2. Create a C++ project in Visual Studio 2012. And have the code window open to write the project code. Display Using Visual Studio to create your program in C++ and follow the instructions on creating the project.
Declare variables to hold information about tank capacity and mpg
Using cout Set up information about this program and what the user will enter and results expected
Ask the user to enter some information requested and save the response to a variable using the cout and cin syntax. Make sure the position for the user to enter information is on the same line as the request for information.
Use line spacing (endl or n) to separate lines of output to make it easy for the user to read the information.
3. Documentation: All lines of code must be documented.
Use the syntax to designate lines in code as comments (//)
These comments can be at the end of a line of code or in a group definition at the beginning of a section of code. All methods and function need a group heading document.
4. Run the program using Ctrl+F5. Debug the code, making sure all calculations are correct and the line spacing is suitable for readability.
Your program Assignment
Write a program named TankOfGas. The program will have the use input into a variable the number of gallons of gas in the gas tank, the miles per gallon in town and the miles per gallon on the highway (Optionally: you can also have the use input MPG for highway and town). Have the program calculate the number of miles traveled in town and on the highway. Display the result on the screen.
Default MPG could be 23.5 miles in town and 28.9 miles on the highway.
Calculate both miles in city and on the highway.
Hint: Distance = Number of Gallons X Average Miles per Gallon
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.