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

For this program, follow Program Guidelines for the Header and Comments. Write a

ID: 3847429 • Letter: F

Question

For this program, follow Program Guidelines for the Header and Comments. Write a C++ program that prompts the user to enter the last name of a family and the total number of pints of blueberries picked by this family on a visit to the local expressed Pick-Your-Own Farm. The program then computes the same amount of fruit, as the number of gallons, quartsand pints. Conversion factors are based on: 4 quarts = 1 gallon 2 pints = 1 quart Label the output to read like a sentence. Include the units of measurement. For example, if the input is 69 pints picked by the Smith family, the output could be: The Smith family picked 8 gallon(s), 2 quart(s) and 1 pint(s). You must turn in: (1) Your hand written algorithm, in English statements; formulas may be used to show the calculations needed, and variables used in the formulas need to be identified. (2) Your source file (.cpp), which runs in Visual C++.Output of two runs which use:161 pints picked by the Jones family 206 pints picked by the Johnson-Walker family is to be pasted at the end of your source code, in a paragraph comment (between/* and */symbols).

Explanation / Answer

Formulas used:

1 gallon = 4 quarts = 8 pints

1) Algorithm

input family_name

input pints

int gallons = pints/8;
int quarts = (pints%8)/2;
int r_pints = pints - 8*gallons - 2*quarts;

print output

2.C++ code:

#include <bits/stdc++.h>
using namespace std;

int main()
{
   string family;
   int pints;
   cout << "Enter the name of family ";
   cin >> family;
cout << "Enter the number of pints ";
cin >> pints;

int gallons = pints/8;
int quarts = (pints%8)/2;
int r_pints = pints - 8*gallons - 2*quarts;
cout << "The " << family << " family picked " << gallons << " gallon(s), " << quarts << " quart(s), " << r_pints << " pints!" << endl;
return 0;
}

Sample Output:

1)

Enter the name of family
Jones
Enter the number of pints
161
The Jones family picked 20 gallon(s), 0 quart(s), 1 pints!

2)

Enter the name of family
Jonhnson-walker
Enter the number of pints
206
The Jonhnson-walker family picked 25 gallon(s), 3 quart(s), 0 pints!

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