Question

Goals: Practicing functions and parameter types. Problem: You are to create a program that will aid in a farmer in monitoring
#include <iostream> #include <string> //include other library files as needed using namespace std; int main() /define (declar
0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

#include<iostream>

#include<string>

using namespace std;

int CheckInput(int value, string whatisit, int lowest, int highest);

void calcPackage(int kgs, int &bags, int &lots, int &pallets, int &unpack);

int main(){

int kgs;

cout<<"Enter value for corn produced in kilograms: ";

cin>>kgs;

kgs = CheckInput(kgs, "corn", 0, 10000);

int bags, lots, pallets, unpack;

calcPackage(kgs, bags, lots, pallets, unpack);

cout<<"You picked "<<kgs<<" kilograms of corn which corresponds to "<<pallets<<" pallets, "<<lots<<" lots, and "<<bags<<" bag, with "<<unpack<<" kilograms left over"<<endl;

return 0;

}

int CheckInput(int value, string whatisit, int lowest, int highest){

while(value<lowest || value>highest){

cout<<"The "<<whatisit<<" must be between "<<lowest<<" and "<<highest<<"."<<endl;

cout<<"Enter the "<<whatisit<<" again. ";

cin>>value;

}

return value;

}

void calcPackage(int kgs, int &bags, int &lots, int &pallets, int &unpack){

int available = kgs;

pallets = available/1200;

available = available%1200;

lots = available/200;

available = available%200;

bags = available/20;

unpack = available%20;

}

Add a comment
Know the answer?
Add Answer to:
Goals: Practicing functions and parameter types. Problem: You are to create a program that will aid...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you help me to create this program, please? Prompt the user for the user for...

    Can you help me to create this program, please? Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...

  • Thank you! /*Lab 8 : Practicing functions and arrays Purpose: */ #include<iostream> #include<fstream> using namespace std;...

    Thank you! /*Lab 8 : Practicing functions and arrays Purpose: */ #include<iostream> #include<fstream> using namespace std; int read_function(int array[], int, int); int main() { int array[300], numba; read_function(array[300]); cout << "Enter a whole number between 2-20: " << endl; cin >> numba; read_function(numba); return 0; } int read_funtion (int arr[300], int num, int Values) { int sum=0; ifstream array_file; array_file.open("Lab8.dat"); for(int i=0; i < 300; i++) {   array_file >> arr[i];   cout << arr[i];   sum += i; } cout << sum;...

  • Write a function PoundsToKilograms that: Takes a number of pounds (an integer) as a parameter, Calculates...

    Write a function PoundsToKilograms that: Takes a number of pounds (an integer) as a parameter, Calculates and returns the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. In the main section of the program: Prompt the user to input a weight in pounds, Call the function you wrote to transform the weight into kilograms, Output the weight in kilograms; the number must be shown with 2 decimals after the decimal point. Your program must define and call...

  • PROJECT 6    Functions You are to write a PYTHON program which: *Defines the following 4  functions: whoamI()...

    PROJECT 6    Functions You are to write a PYTHON program which: *Defines the following 4  functions: whoamI() This function prints out your name and lists any programming course you have taken prior to this course. isEven(number) This function accepts one parameter, a number, and prints out a message indicating if the number is even or odd. Keep in mind that a number is even if there is no remainder when the number is divided by two. printEven(number) This function accepts one...

  • Problem: Create a program that contains two functions: main and a void function to read data...

    Problem: Create a program that contains two functions: main and a void function to read data from a file and process it. Your main function should prompt the user to enter the name of the file (Lab7.txt), store this name, and then call the function sending the name of the file to the function. After the function has completed, the main function should output the total number of values in the file, how many of the values were odd, how...

  • In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a...

    In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • code in C++ Create a program that uses the pass by reference operator instead of the...

    code in C++ Create a program that uses the pass by reference operator instead of the return command. Your main program will need to: create empty variables call void function 1 with no input to display your name to the screen call function 2 to collect the square feet that a gallon of paint covers from user call function 2 to collect the square feet of wall that needs to be painted call function 3 to calculate the number of...

  • You are to write three functions for this lab: mean, remove, display. Download the main.cpp file...

    You are to write three functions for this lab: mean, remove, display. Download the main.cpp file provided to get started. Read the comments in the main function to determine exactly what the main function should do. //include any standard libraries needed // - Passes in an array along with the size of the array. // - Returns the mean of all values stored in the array. double mean(const double array[], int arraySize); // - Passes in an array, the size...

  • Q2. To check and print if entered integer is prime or not. Prompt the user to...

    Q2. To check and print if entered integer is prime or not. Prompt the user to enter a positive integer or 0 to exit. while negative integer entered - prompt for valid values again. If positive integer entered - check if it is prime. Write a separate function that accepts a positive integer as argument and checks and returns 1 if the integer is prime or 0 if it is not prime. Call the function from main. Accept the return...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT