One gram of fat has 9 calories. If you know the number of fat grams in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
One gram of fat has 9 calories. If you know the number of fat grams in a particular food, you can use the following formula to calculate the number of calories that come from fat in that food: Calories from fat = Fat grams × 9 If you know the food's total calories, you can use the following formula to calculate the percentage of calories from fat: Percentage of calories from fat = Calories from fat - Total calories Create an application that allows the user to enter: • The total number of calories for a food item • The number of fat grams in that food item The application should calculate and display: • The number of calories from fat • The percentage of calories that come from fat Also, the application's form should have a CheckBox that the user can check if he or she wants to know whether the food is considered low fat. (If the calories from fat are less than 30% of the total calories of the food, the food is considered low fat.) Use the following test data to determine if the application is calculating properly: Calories and Fat Percentage Fat 200 calories, 8 fat grams Percentage of calories from fat: 36% 150 calories, 2 fat grams Percentage of calories from fat: 12% (a low-fat food) 500 calories, 30 fat grams Percentage of calories from fat: 54% Note: Make sure the number of calories and fat grams are not less than 0. Also, the number of calories from fat cannot be greater than the total number of calories. If that happens, display an error message indicating that either the calories or fat grams were incorrectly entered. One gram of fat has 9 calories. If you know the number of fat grams in a particular food, you can use the following formula to calculate the number of calories that come from fat in that food: Calories from fat = Fat grams × 9 If you know the food's total calories, you can use the following formula to calculate the percentage of calories from fat: Percentage of calories from fat = Calories from fat - Total calories Create an application that allows the user to enter: • The total number of calories for a food item • The number of fat grams in that food item The application should calculate and display: • The number of calories from fat • The percentage of calories that come from fat Also, the application's form should have a CheckBox that the user can check if he or she wants to know whether the food is considered low fat. (If the calories from fat are less than 30% of the total calories of the food, the food is considered low fat.) Use the following test data to determine if the application is calculating properly: Calories and Fat Percentage Fat 200 calories, 8 fat grams Percentage of calories from fat: 36% 150 calories, 2 fat grams Percentage of calories from fat: 12% (a low-fat food) 500 calories, 30 fat grams Percentage of calories from fat: 54% Note: Make sure the number of calories and fat grams are not less than 0. Also, the number of calories from fat cannot be greater than the total number of calories. If that happens, display an error message indicating that either the calories or fat grams were incorrectly entered.
Expert Answer:
Related Book For
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis
Posted Date:
Students also viewed these programming questions
-
In this exercise, you create an application that allows the user to enter the gender (either F or M) and GPA for any number of students. The applications interface is shown in Figure 6-53. The...
-
Write an application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entered is less than 0 or more than 10, display an appropriate message and do...
-
Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a...
-
The Federal Reserve may raise its benchmark interest rate later this month. How is this achieved? Why would they do this? Explain the consequences fully. (Include graphs with your answer)
-
What is kaizen, and why is it so important for successful lean production?
-
Consider the following test of whether a coin is fair. Toss the coin three times. If the coin lands either all heads or all tails, reject H0: p = 1 / 2. (The p denotes the chance for the coin to land...
-
An auditor can accept an assurance engagement only where the practitioners preliminary knowledge of the engagement circumstances indicates that: (a) Relevant ethical requirements, such as...
-
Edington Electronics Inc. produces and sells two models of pocket calculators, XQ-103 and XQ-104. The calculators sell for $12 and $25, respectively. Because of the intense competition Edington...
-
Current Attempt in Progress * Your answer is incorrect. For its three investment centers, Gerrard Company accumulates the following data: Sales Controllable margin III $1,980,000 1,386,000 $4,056,000...
-
Sukdev Basi funded an irrevocable simple trust in May 2008. The trust benefits Sukdev's son for life and grandson upon the son's death. One of the assets he transferred to the trust was Jetco stock,...
-
Question 1 (1 point) Lego is liked by children as well as adults. Management at a lego company wonders if lego sets purchased for adults are on average more expensive than than lego purchased for...
-
True or False. Lagrange's equation cannot be used to derive the equations of motion of a multi-degree-of-freedom system.
-
A mass of \(110 \mathrm{~kg}\) is hung from a spring in a local gravitational field where \(g=9.806 \mathrm{~m} / \mathrm{s}^{2}\), and the spring is found to deflect by \(30 \mathrm{~mm}\). If the...
-
True or False. For a multi-degree-of-freedom system, one equation of motion can be written for each degree of freedom.
-
Matthew (who was born on 1 October 1934) dies on 23 December 2023. His only income in tax year 2023-24 is a retirement pension of 35,130. He made a Gift Aid donation of 200 in July 2023. His wife has...
-
True or False. The product of stiffness and flexibility matrices of a system is always an identity matrix.
-
Blossom Inc. has two temporary differences at the end of 2024. The first difference stems from installment sales, and the second one results from the accrual of a loss contingency. Blossom's...
-
Write an if statement that displays the message "The number is not valid" if the variable speed is outside the range 0 through 200.
-
True or False: When passing multiple arguments to a method, the order in which the arguments are passed is not important.
-
In this chapter we used the metaphor of a kite attached to a spool of string to describe the relationship between an object and a reference variable. In this metaphor, does the kite represent an...
-
\((7 \sqrt{33}) \times(8 \sqrt{66})\) Perform the arithmetic operations without a calculator, if possible. If it is not possible, state why.
-
\((4 \sqrt{15}) \times(3 \sqrt{10})\) Perform the arithmetic operations without a calculator, if possible. If it is not possible, state why.
-
\((70 \sqrt{30}) \div(14 \sqrt{6})\) Perform the arithmetic operations without a calculator, if possible. If it is not possible, state why.
Study smarter with the SolutionInn App