Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your solution ( identification headers ) must include the following: Flowchart Pseudo - code Program coded Program outpuT Problem Statement Design a program that asks

Your solution (identification headers) must include the following:
Flowchart
Pseudo-code
Program coded
Program outpuT
Problem Statement
Design a program that asks for the number of fat grams and calories in a food item to determine the percentage of calories from fat. Validate input as follows:
The number of fat grams must be at least 0.
The number of calories must be at least 0.
The number of calories cannot be less than fat grams *9.
After input has been validated, use the following formula to determine the percentage of calories from fat:
Percentage of calories from fat =(fat grams *9)/ calories.
Your program should consist of the following:
Module main. Calls getFat, getCalories, and showPercent.
Function getFat. Accepts user input of fat grams. Validate user input as a non-negative number and return valid fat grams.
Function getCalories. Accepts user input of total calories. Validate user input as a number that is non-negative and greater than or equal to (fat grams *9). Return a valid number of calories.
Module showPercent. Displays percent of fat in the food item, determined by this formula: (fat grams *9)/ calories. Displays a message indicating the food item is "low fat" if the percentage of fat is less than 30%(0.3).
Expected Output
Your output should be similar to the following:
Please enter the number of fat grams: 20
Please enter the number of calories: 100
The number of calories cannot be less than the number of fat grams *9.
Please enter the number of calories. 200
The percentage of calories from fat is 80.0 percent.
Please enter the number of fat grams: -1
The number of fat grams cannot be less than 0.
Please enter the number of fat grams. 10
Please enter the number of calories. 350
The percentage of calories from fat is 25.7.
That food item is considered "low fat".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

name the compounds C. E. F. C. E. F

Answered: 1 week ago

Question

Write formal and informal proposals.

Answered: 1 week ago

Question

Describe the components of a formal report.

Answered: 1 week ago

Question

Write formal and informal reports.

Answered: 1 week ago