1)john raymond was so pleased with the program you created for his clients that
ID: 3534660 • Letter: 1
Question
1)john raymond was so pleased with the program you created for his clients that he regers you to his coworker,a nutrionist in the same facility.The nutrionist would like you to create a program that calculates fat grams and calories.Design a program that asks for the number of fat grams and calories in a food item.Validate the input as follows:
-make sure the number of fat grams and calories are not less then 0.
-according to nutritional formulas,the number of calories cannot exceed fat grams x 9 . Make sure that the number of calories entered is not greater than fat grams x9.
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 x 9) / calories
some nutritionist classify a food as low fat if less than 30 percent of its calories come from fat.if the results of this fomrula are less then 0.3 the program should display a message indicating the food is low in fat
can someone help me create a flowchart for this one?,i already have a psuedocode ^^
__________________________________________________________________________________________
2)You been asked by a science muesum to create an application that displays information about planets to visitors. When users select a planet they should be able to read information about the selected planet to complete this project:
Create an application that displays the following menu:
select a planet
1.mercury
2.venus
3.earth
4.mars
5.exit the program
enter your selection
When the users select a planet from the menu,the program should disply data about the planets average distance from the sun,the planets mass and the planets surface temeperature.us the folloing data in your program:
1,mercury;
average distance from the sun 57.9 million kilometers
mass 3.31 x 10^24kg
surface temeprature -173 to 430 degress celcius
venus
average distancefrom the sun 108.2 million kilometers
mass 4.87 x 10^24kg
surface temerpature 472 degress celcius
earth average distance from the sun 149.6 million kiolmeters
mass 5.967 x 10^24kg
surface temerparture -50 to 50 degress celcius
mars
averiage distance from the sun 227.9 million kilometers
mass 0.6424 x 10^24kg
surface temperature -140 to 20 degress celcius
CREATE A FLOWCHART
i already have pseudocode for both,
Explanation / Answer
The following is written as a C function but could be easily modified to work in another language. The function returns -1 if input validation fails, or the percentage of calories from fat if it runs successfully.
double fatGramCalculator(double fatGrams, double calories)
{
// If fat grams or calories are less than 0, print a message and return -1
if (fatGrams < 0 || calories < 0)
{
printf("Number of fat grams and calories must be greater than 0 ");
return -1;
}
// If calories is greater than fat grams * 90, print a message and return -1
if (calories > (fatGrams * 9)
{
printf("Calories must not exceed fat grams x 9 ");
return -1;
}
// Calculate percentage of calories from fat
double caloriesFromFat = (fatGrams * 9) / calories;
// Print calories from fat, multiplying percentage by 100 to remove decimal point
printf("%d percent of calories from fat ", caloriesFromFat * 100);
// If less than 30% of calories come from fat, print a message
if (caloriesFromFat < 0.3)
{
printf("Food is low in fat ");
}
// Return the number of calories from fat
return caloriesFromFat;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.