I am having a problem with my static casting. I keep getting only one response no matter what values I use in the program. It's as the bottom half of my program is not executing. I cannot figure out...


I am having a problem with my static casting. I keep getting only one response no matter what values I use in the program. It's as the bottom half of my program is not executing. I cannot figure out what I am doing incorrectly. I am sure it is obvious, but after looking for two days I don't see it.


/*
Program: CL8_Zick_Ursula
Author: Ursula Zick
Date: 02/13/2019
Purpose: Calculate the percentage of calories from fat
*/


#include
#include
using namespace std;


int main()
{
// Variants
int fatGrams; // Total number of calories in one gram of fat
int fatCalories; // Total amount of calories from fat
int totalCalories; // Total number of calories from fat
int fatPercentage; // Total fat percentage from calories


cout < "enter="" the="" requested="" information="" to="" determine="" the="" percentage="" of="" fat="" in="" food="" item;="">


// Get the total calories from food item
cout < "enter="" the="" total="" calories:="">
cin >> totalCalories;


// Get the total fat grams from food item
cout < "enter="" the="" total="" fat="" grams:="">
cin >> fatGrams;


// Convert the fat calories to fat grams
fatCalories = fatGrams * 9;


// Determine if fat gram is less than zero
if (totalCalories < 0="" ||="" fatgrams=""><>
cout < "="" total="" calories="" or="" fat="" grams="" can="" not="" be="" less="" than="" zero="">
else
{
if (fatCalories > totalCalories)
cout < "\ninvalid="" -="" there="" are="" more="" calories="" in="" fatgrams="">
< "grams="" of="" fat="" than="" you="" entered="" for="" total="" calories:="">
}
// Static cast on the fat percentage
fatPercentage = static_cast (fatCalories) / totalCalories;


// Calculate fat percentage
if (fatPercentage *= 100)
cout < "percentage="" of="" fat:="">
else
{
if (fatPercentage <>
cout < "\nthat="" food="" is="" low="" in="" fat:="">
else

cout < "\nthat="" food="" is="" not="" low="" in="">
}


return 0;
}

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here