Design a program that asks for the number of fat grams

Assignment Help C/C++ Programming
Reference no: EM13166665

 Starting out with Programming logic and design 3rd Author Tony Gaddis - Pg 279, PE 3 Fat Grams Calculator

 

Design a program that asks for the number of fat grams and calories in a food item and Validate the input

 

Please help me with the structure and the order of the statements.

 

This is supose to be written in pseudocode

 

Declare Integer calories, fatGrams, maxGrams

Declare Real pFatcal

 

Display "Please Enter the number calories in the food item."

Input calories

 

// Confirm calories not less than zero.

While calories < 0

Display "ERROR: The number of calories can't be less than zero."

Display "Please enter a valid number of calories."

Input calories

End While

 

Display "Please Enter the number fatGrams in the food item."

Input fatGrams

 

// Confirm fat Grams not less than zero.

While fatGrams < 0

Display "ERROR: The number of fat grams can't be less than zero."

Display "Please enter a valid number of fat grams."

Input fatGrams

End While

 

// Calculate percentage of calories from fat

// according to nutritional formulas, the number of calories can't exceed fat grams times 9

// confirm calories entered are not greater than fatGrams times 9.

 

maxGrams = fatGrams * 9

 

While calories <= maxGrams

pFatcal = (fatGrams * 9)/ calories

Display "The percentage of calories from fat is:   " pFatcal

 

// Check to see if the item is low fat.

If pFalcal < 0.3

Display "Great Work! This food item is Low Fat. "

End If

 

 

Reference no: EM13166665

Questions Cloud

Calculate the mass of ethylene glycol : Calculate the mass of ethylene glycol (C2H6O2) that must be added to 1.00 kg of ethanol (C2H5OH) to reduce its vapor pressure by 14.2 torr at 35°C. The vapor pressure of pure ethanol at 35°C is 1.00 x102 torr.
Explain assign absolube stereochemistry : assign absolube stereochemistry (R or S) to each of the stereocenters in (+)menthol
Explain the general idea of the lcao-mo method : Explain the general idea of the LCAO-MO method.
Explain mole of solid ammonium chloride : Determine the pH of a solution prepared by adding 0.0500 mole of solid ammonium chloride to 100 mL of a 0.150-molar solution of ammonia.
Design a program that asks for the number of fat grams : Starting out with Programming logic and design 3rd Author Tony Gaddis - Pg 279, PE 3 Fat Grams Calculator
Use spreadsheet journal entries to prepare the journal entry : Pretax financial income for 2012 is $100,000 and the tax rate enacted for 2012 and future years is 40%.
Demonstrate overriding of their getter and setter methods : Organize following animals using classes and virtual function. tigers,crocodile, elephants,pythons,zebras,hawks, chickens,rabbits using at least 3 properties some of the animals share. demonstrate overriding of their getter and setter methods.
Calculate the partial pressure of o2 : a tank contains 150.0 g of co2 and 24.0 g o2 at a total pressure of 4.25 atm and a tempature of 25.0*C. Calculate the partial pressure of O2.
Goto statements to explicitly : Rewrite the following program fragment using goto statements to explicitly show the flow control through the loop.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a c program which takes a string from command line

Write a c program which takes a string from command line with mainfunction has no parameter and convert the string in upperca

  Presented a number of recurrence relations

For this problem set, you will be presented a number of recurrence relations and asked to state their actual time complexity, showing your work in the process.

  What output would be produced by the program segment

What output would be produced by the following program segment?

  Implement the delivery company

Implement the delivery company using the classes given in the class diagram above.

  Build a table of reynolds numbers at flow velocities

Write a program code to compute and build a table of Reynolds numbers at flow velocities varying from 100 to 1000 ft/sec (at increments of 100)

  The rpn calculator program

The RPN calculator program should read the RPN expression as an entire line from stdin.Input will consist of a single line. After completing the evaluation of the expression, the program should print the contents of the entire stack, starting with th..

  Program that asks the user to enter up to 100 integer score

Write a C program that asks the user to enter up to 100 integer scores, which are to be stored in an array. (You should allow the user to terminate input prior to entering all 100 scores.) The program should then display all the scores, ten per line,..

  A constructor that constructs a rectangle2d

A constructor that constructs a Rectangle2D with specified points as coordinates.A no-argument constructor that creates the rectangle with points (0, 0), (5, 5) and (0, 5) and

  Write function compute square root together with prototype

Write a C++ function called compute together with its prototype that is passed 2 integers, A and B and returns the square root of A2+B2 ,as a double.

  Write a function that takes an integer array

1. Write a function that takes an integer array and the array's size as parameters. The function will check if the array is sorted. If it is, it will return a 1. If it is not sorted it will return 0. The function should not  sort the array.

  Prepare a program that uses at least two functions

Prepare a program that uses at least two functions that can be called from your main.

  The first will be a structure called point

Create two structures. The first will be a structure called Point and will have as its data members an x and y coordinate. The second will be called Line and will have two Point structures as its data members.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd