Answered step by step
Verified Expert Solution
Question
1 Approved Answer
okay, so basically this is the whole question with all steps. Control property settings This statement declares a double variable named mpg. This variable is
okay, so basically this is the whole question with all steps.
Control property settings This statement declares a double variable named mpg. This variable is used to hold the MPG, which will be calculated. The statement converts the milesTextBox control's Text property to a double and assigns the result to the miles variable. This statement converts the qallonsTextBox control's Text property to a double and assigns the result to the miles variable. This statement converts the gallonsTextBox control's Text property to a double and assigns the result to the gallons variable. This statement calculates MPG. It divides the miles variable by the gallons variable and assigns the result to the mpg variable. This statement converts the mpg variable to a string and assigns the result to the mpgLabel control's Text property. This causes the value of the mpg variable to be displayed in the mpgLabel control. Switch your view back to the Designer and double click the exiButton control. In the code editor you will see an empty event handler named exitButton_click, Complete the exitButton_click event handler by typing the code shown in lines 43-44 in Program 3-2. Save the project. Then, press the key on the keyboard or click the Start Debugging button on the toolbar to compile and run the application. Test Calculate MPG button. The MPG should be displayed, similar to Figure 3-18. Click the Exit button and the form should close. The Fuel Economy application. In the United States, a car's fuel economy is measured in rules per gallon, or MPG. You are the following formula to calculate a car's MPG. MPG = Males driven + Gallons of gas mind Is this national you will create an application that less the existed the number of miles he or she has driven the gallons of gas used. The application will calculate and display the car's MPG. Figure 3-17 shows the application's form, with the names of all the controls. When the application runs, the user enter the number of miles driven into the milesTextBox control and the gallons of gas used into the gallonsTextBox control. When the user clicks the control, the application calculates the car's MPG and displays the result in the control. The exitButton control closes the application's form. The Fuel company form Start Visual Studio and begin a new Windows Forms Application project named fuel Economy. Set up the application's form as shown in Figure 3-17. Notice that the form's Text property is set to Fuel Economy. The names of the controls are shown in the figure. As you place each of the controls on the form, refer to Table 3-8 for the relevant property settings. Once you have set up the form with its controls, you can create the Click event handlers for the Button controls. At the end of this tutorial, Program 3-2 shows the completed code for the form. You will be instructed to refer to Program 3-2 as you write the even handlers, (Remember, the line numbers that are shown in Program 3-2 are not part of the program. They are shown for reference only.) In the Designer, double-click the calculateButton control. This opens the code editor, and you will see an empty event handler named calculateButton_Click. Complete the calculateButton_Click event handler by typing the code shown in lines 22-38 in Program 3-2. Let's take a closer look at the code: This statement declares a double variable named miles. This variable is used to hold the number of miles driven. This statement declares a double variable named gallons. This variable is used to hold the number of gallons usedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started