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_UrsulaAuthor: Ursula ZickDate: 02/13/2019Purpose: Calculate the percentage of calories from fat*/ #include<iostream>#include<iomanip>using namespace std; int main(){// Variantsint fatGrams; // Total number of calories in one gram of fatint fatCalories; // Total amount of calories from fatint totalCalories; // Total number of calories from fatint fatPercentage; // Total fat percentage from calories cout << "Enter the requested information to determine the percentage of fat in food item; \n\n"; // Get the total calories from food itemcout << "Enter the total calories: ";cin >> totalCalories; // Get the total fat grams from food itemcout << "Enter the total fat grams: ";cin >> fatGrams; // Convert the fat calories to fat gramsfatCalories = fatGrams * 9;// Determine if fat gram is less than zeroif (totalCalories < 0 || fatGrams < 0)cout << " Total calories or fat grams can not be less than zero ";else{if (fatCalories > totalCalories)cout << "\nInvalid - There are more calories in fatGrams \n"<< "grams of fat than you entered for total calories: ";}// Static cast on the fat percentagefatPercentage = static_cast <double> (fatCalories) / totalCalories; // Calculate fat percentageif (fatPercentage *= 100)cout << "Percentage of fat: ";else{if (fatPercentage < 30.0)cout << "\nThat food is low in fat: \n\n";else cout << "\nThat food is not low in fat:";}return 0;}

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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<iostream>
#include<iomanip>
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; \n\n";

// 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 < 0)
cout << " Total calories or fat grams can not be less than zero ";
else
{
if (fatCalories > totalCalories)
cout << "\nInvalid - There are more calories in fatGrams \n"
<< "grams of fat than you entered for total calories: ";
}
// Static cast on the fat percentage
fatPercentage = static_cast <double> (fatCalories) / totalCalories;

// Calculate fat percentage
if (fatPercentage *= 100)
cout << "Percentage of fat: ";
else
{
if (fatPercentage < 30.0)
cout << "\nThat food is low in fat: \n\n";
else
cout << "\nThat food is not low in fat:";
}

return 0;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY