Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please develop an algorithm which you can follow to write a JavaScript program that satisfies the requirements of the Fat Gram Calculator (Programming Exercise 3,

Please develop an algorithm which you can follow to write a JavaScript program that satisfies the requirements of the Fat Gram Calculator (Programming Exercise 3, page 281)

NOTE: There is an error in the description of the problem. 1 fat gram is equivalent to 9 calories so the number of calories entered should not be less than fat grams * 9.

3. Fat Gram Calculator Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: l Make sure the number of fat grams and calories is not less than 0. l According to nutritional formulas, the number of calories cannot exceed fat grams 9. Make sure that the number of calories entered is not greater than fat grams 9. Once correct data has been entered, the program should calculate and display the percentage of calories that come from fat. Use the following formula: Percentage of calories from fat = (Fat grams 9) Calories Some nutritionists classify a food as low fat if less than 30 percent of its calories come from fat. If the results of this formula are less than 0.3, the program should display a message indicating the food is low in fat.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How would you respond to each of the girls?

Answered: 1 week ago