Assume that a bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 servings in the bag and that a serving equals 300 calories. Create a VB application that lets the user enter the number of cookies he or she actually ate and then reports the number of total calories consumed. If the user fails to enter a numeric value, display an appropriate error message and do not attempt to perform calculations.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Pearson eText for Starting Out With Visual Basic -- Instant Access (Pearson+)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Starting out with Visual C# (4th Edition)
Problem Solving with C++ (10th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with Programming Logic and Design (4th Edition)
- For each of the following exercises, you may choose to write a console-based or GUI application, or both. Write a program for The Carefree Resort named ResortPrices that prompts the user to enter the number of days for a resort stay. Then display the price per night and the total price. Nightly rates are $200 for one or two nights; $180 for three or four nights; $160 for five, six, or seven nights; and $145 for eight nights or more.arrow_forwardThe purpose of this exercise is to demonstrate the importance of testing an application thoroughly. Open the FixIt Solution.sln file contained in the VB2017\Chap04\FixIt Solution folder. The application displays a shipping charge that is based on the total price entered by the user, as shown in Figure 4-64. Start the application and then test it by clicking the Display shipping button. Notice that the Shipping charge box contains $13, which is not correct. Now, test the application using the following total prices: 100, 501, 1500, 500.75, 30, 1000.33, and 2000. Here too, notice that the application does not always display the correct shipping charge. (More specifically, the shipping charge for two of the seven total prices is incorrect.) Open the Code Editor window and correct the errors in the code. Save the solution and then start and test the application.arrow_forwardThe Donut Shoppe sells four varieties of doughnuts: Glazed (1.05), Sugar (1.05), Chocolate (1.25), and Filled (1.50). It also sells regular coffee (1.50) and cappuccino (2.75). The store manager wants you to create an application that displays a customers subtotal, 6% sales tax, and total due. Create a Windows Forms application. Use the following names for the project and solution, respectively: Donut Project and Donut Solution. Save the application in the VB2017\Chap06 folder. Create the interface shown in Figure 6-57. When coding the application, use one independent Sub procedure to determine the subtotal, which is the total cost without the sales tax. Use a function to determine the sales tax. Use an event-handling Sub procedure to clear the output. Save the solution and then start and test the application.arrow_forward
- Create a lottery game application named Lottery. Generate three random numbers, each between 1 and 4. Allow the user to guess three numbers. Compare each of the users guesses to the three random numbers, and display a message that includes the users guess, the randomly determined three-digit number, and the amount of money the user has won as follows: Â Make certain that your application accommodates repeating digits. For example, if a user guesses 1, 2, and 3, and the randomly generated digits are 1, 1, and 1, do not give the user credit for three correct guesses-just one.arrow_forwardIn Chapter 2, you created an interactive application named GreenvilleRevenue, and in Chapter 3 you created a GUI version of the application named GreenvilleRevenueGUI. The programs prompt a user for the number of contestants entered in this years and last years Greenville Idol competition, and then they display the revenue expected for this years competition if each contestant pays a $25 entrance fee. The programs also display a statement that compares the number of contestants each year. Now, replace that statement with one of the following messages: If the competition has more than twice as many contestants as last year, display The competition is more than twice as big this year! If the competition is bigger than last years but not more than twice as big, display The competition is bigger than ever! If the competition is smaller than last years, display, A tighter race this year! Come out and cast your vote!arrow_forwardIn Chapter 2, you created a program for Marshalls Murals that prompts a user for the number of interior and exterior murals scheduled to be painted during the next month. The program computes the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each. The application should display, by mural type, the number of murals ordered, the cost for each type, and a subtotal. The application also displays the total expected revenue and a statement that indicates whether more interior murals are scheduled than exterior ones. Now create an interactive GUI program named MarshallsRevenueGUI that performs all the same tasks.arrow_forward
- Create an application that calculates a car’s gas mileage. The formula for calculating the miles that a car can travel per gallon of gas is: MPG=milesgallonsIn the formula MPG is miles-per-gallon, miles is the number of miles that can be driven on a full tank of gas, and gallons is the number of gallons that the tank holds. The application’s form should have TextBox controls that let the user enter the number of gallons of gas the tank holds and the number of miles the car can be driven on a full tank. When the Calculate MPG button is clicked, the application should display the number of miles that the car can be driven per gallon of gas. The form should also have a Clear button that clears the input and results, and an Exit button that ends the application. If the user fails to enter numeric values, display an appropriate error message and do not attempt to perform calculations.arrow_forwardTip, Tax, and Total Create an application that lets the user enter the food charge for a meal at a restaurant. When a button is clicked, the application should calculate and display the amount of a 15 percent tip, 7 percent sales tax, and the total of all three amounts.arrow_forwardWhen an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period:d =1/2 gt2The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time in seconds that the object has been falling. Create an application that allows the user to enter the amount of time that an object has fallen and then displays the distance that the object fell. The application should have a method named FallingDistance. The FallingDistance method should accept an object’s falling time (in seconds) as an argument. The method should return the distance in meters that the object has fallen during that time interval.arrow_forward
- Falling Distance When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d =1/2gt2 The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time in seconds that the object has been falling. Create an application that allows the user to enter the amount of time that an object has fallen and then displays the distance that the object fell. The application should have a method named FallingDistance. The FallingDistance method should accept an object’s falling time (in seconds) as an argument. The method should return the distance in meters that the object has fallen during that time interval.arrow_forwardSales Tax and Total Create an application that allows the user to enter the amount of a purchase. The program should then calculate the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the total sales tax).arrow_forwardCreate an application that allows the user to enter their monthly. Your program should display the following: Total expenses Amount over/under budget for EVERY expense category Label displaying if they are over/under budget AND the total amount that they are over/under budget for the month The following table shows the Expense Categories and the budgeted Expense Amount per month: Rent: $775.00 Light Bill: $275.00 Cable: $60.50 Car Payment: $325.00 Insurance: $125.76 Grocery: $300.00 Miscellaneous: $100.00arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage