Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a math tutor program that randomly selects two numbers between 1 and 100 a

ID: 641489 • Letter: W

Question

Write a math tutor program that randomly selects two numbers between 1 and 100 and invites the student to add them together. Your program should provide the correct answer and congratulate the student if they got the answer correct or show the correct answer and offer some words of encouragement to try again. Hint: if...else 2. Rework your number guessing game from the previous homework to include the use of the || operator to confirm user input is between 1 and 100. Hint: This may require the use of a trailing else and the use of the OR logical operator. 3. Create a geometry calculator that displays a menu. Choices on the menu include: Calculate the area of a circle (pi = 3.14159, user inputs radius) Calculate the area of a rectangle (user inputs height and length of rectangle sides) Calculate the area of a triangle (user inputs base length and triangle height) Your program should validate all inputs. Hint: This will require nested if statements and a trailing else 4. Create a fat gram calculator. User should input calories per serving and fat grams per serving. The program should: Calculate the number of calories from fat per serving (fat grams * 9) Calculate the percentage of fat per serving (fat calories per serving / calories per serving) Provide the calories from fat per serving, percentage of fat per serving If percentage of fat per serving is equal to or less than 30%, feedback should advise this is a low fat food. If percentage of fat is greater than 30%, the food is not low fat. Your program should validate all inputs as negative numbers are not acceptable and calories per serving should not be zero.

Explanation / Answer

geometry_calculator.cpp

main.cpp

//System Libraries
#include <iostream>
using namespace std;
//User Libraries
//Global Constants
//Function Prototypes
//Execution Begins Here
int main(int argc, char** argv)
{//Execution Begins Here!
    int   cal, fatGram; //number of calories/serving and total fat grams/serving
    float calFat,percCal; //total calories from fat and percentage of calories from fat
    //Prompt user for number of calories and fat grams
    cout<<"This program calculates the percentage of calories that come from fat. ",
    cout<<"Please enter the number of calories per serving of a particular food: "<<endl;
    cin>>cal;//input calories
    cout<<"Please enter the number of fat grams per serving of a particular food "<<endl;
    cin>>fatGram;//input fat grams
    calFat = fatGram * 9; //calculate calories from fat
    percCal= (calFat/cal)*100; //calculate percentage of calories from fat
    //output results
    if (cal >0 && cal > calFat && fatGram> 0)
        cout<<"The percentage of calories that come from fat are: "<<percCal<<" %"<<endl;
    else if (cal < calFat)
        cout<<"Error!! The number of calories from fat cannot be greater than the total number of calories. ",
        cout<<"Either the fat grams or the calories were entered incorrectly. Please try again."<<endl;
    else   
        cout<<" Invalid Entry!! The number of calories and number of fat grams must be greater than 0."<<endl;
   
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote