Patti Garcia owns two cars, referred to as Car 1 and Car 2. She wants to drive

Question:

Patti Garcia owns two cars, referred to as Car 1 and Car 2. She wants to drive one of the cars to her vacation destination, but she’s not sure which one (if any) would cost her the least amount in gas. Create a Windows Forms application. Use the following names for the project and solution, respectively: Car Project and Car Solution. Save the application in the VB2017\Chap04 folder. Change the form file’s name to Main Form.vb. Change the form’s name to frmMain. 

a. The application’s interface should provide text boxes for Patti to enter the following five items: the total miles she will drive, Car 1’s miles per gallon (mpg), Car 2’s miles per gallon (mpg), Car 1’s cost per gallon of gas, and Car 2’s cost per gallon of gas. (The cost per gallon of gas must be entered separately for each car because one car uses regular gas and the other uses premium gas.) The interface should display the total cost of the gas if she takes Car 1 and the total cost of the gas if she takes Car 2; display both amounts with a dollar sign and two decimal places. It should also display the car she should take (either Car 1 or Car 2) and approximately how much she will save by taking that car (show the savings with a dollar sign and no decimal places). If the total cost of gas would be the same for both cars, Patti should take Car 1 because that is her favorite car. 

b. The three text boxes that get the trip miles and the miles per gallon should accept only numbers and the Backspace key. The two text boxes that get the cost per gallon should accept only numbers, the period, and the Backspace key. 

c. When a text box receives the focus, its existing text should be selected.

d. The output should be cleared when a change is made to the contents of a text box in the interface.
e. Test the application using 1200, 28, 35, 1.97, and 2.09 as the trip miles, Car 1’s mpg, Car 2’s mpg, Car 1’s cost per gallon, and Car 2’s cost per gallon, respectively. (The total costs for Car 1 and Car 2 are $84.43 and $71.66, respectively. By taking Car 2, Patti will save approximately $13.)
f. Now, change Car 1’s mpg to 35. Also, change Car 2’s mpg to 28. Which car should Patti take, and how much (approximately) will she save?
g. Next, change Car 1’s mpg and cost per gallon to 28 and 2.09, respectively. Which car should Patti take, and how much (approximately) will she save?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: