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)
-
Search the Internet for a recent graph of market volatility. What does this history suggest about the history of consumption growth? The following annual excess rates of return were obtained for nine...
-
The different species of fish sold by a pet shop store. Classify each variable as qualitative or quantitative.
-
Apex Accounting, Inc., has cash of \($2,000\), supplies costing \($800\), and stockholders equity of \($1,300\). Determine the liabilities of the business. Write the accounting equation for Apex...
-
Vista Company Inc. had a beginning inventory of 100 units of Product RST at a cost of $8 per unit. During the year, purchases were: Vista Company uses a periodic inventory system. Sales totaled 1,500...
-
Why are you learning tax accounting? Does your why in any way related to the business "why"? No plagiarism please.
-
1. This family business has made numerous transitions. It started as two brothers and their wives (Whitehall), then became a husband and wife team (Judds Hill), and finally parents with their son and...
-
Suppose that y = 4(x+3). Find dy 33 dx dy da
-
Looking at the Board of Certified Safety Professionals' code of ethics, which two items do you perceive as the most important and why?
-
In the accounting for Research and Development (R&D) Credits, what is the key criterion for recognizing these credits as assets?
-
Human wants are greater than the resources that are available to satisfy them." Discuss the above statement.
-
Consider an individual who immigrates to Canada and deposits $5,000 into the Canadian banking system. Suppose that all commercial banks have a target reserve ratio of 5 percent and that individuals...
-
An investment of $10,000 has a geometric mean return of 0.1475 after 4 years. What is the value of the investment at the end of year four?
-
3) A control system designed to maintain a desired torque on a shaft is represented by the block diagram shown. The transient response specifications to be provided are selected as follows. Determine...
-
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...
-
Derive Eqs. (E.7) and (E.8) of Example 8.10. Data From Example 8.10:- Equation E.7 and E.8:- Determine the effects of rotary inertia and shear deformation on the natural frequencies of a simply...
-
(a) Derive a general expression for the response of a uniform beam subjected to an arbitrary force. (b) Use the result of part (a) to find the response of a uniform simply supported beam under the...
-
Derive Eqs. (E.5) and (E.6) of Example 8.10. Data From Example 8.10:- Equation E.5 and E.6:- Determine the effects of rotary inertia and shear deformation on the natural frequencies of a simply...
Study smarter with the SolutionInn App