Question
WRITE IN C++ The WhatsLeft Function We will be writing a simple program that figures out how many cherries are left. The program will ask
WRITE IN C++
The WhatsLeft Function
We will be writing a simple program that figures out how many cherries are left. The program will ask the user how many cherries they bought and how many cherries they have eaten. Then the program will call a function that returns how many cherries are left and the program will display the result.
This is a simple program and could all be done in main. However, we want to see how toorganize a program using a function and a library so we will add the function declaration and the function implementation in the library as explained.
In Questions 2-4, you will be writing the code that would go in the following files.
- library.cpp
- library.h
- main.cpp.
For this question we will work in library.h.
To Do:
- Write the function declaration for a function calledWhatsLeft.
This function takestwo float parameters passed by value.
- amount of fruit purchased (in pounds)
- amount of fruit eaten (in pounds)
The functionreturns one float.
- amount of fruit left (in pounds)
This declaration would go in the file library.h. You can assume the following code is already in library.h. You will need to add the code listed above.
For this question we will write the implementation of the WhatsLeft function.
To Do:
- Write the implementation for the WhatsLeft function declared in the previous question. Have this functionreturn how many cherries are left.
This function takestwo float parameters passed by value.
- amount of fruit purchased (in pounds)
- amount of fruit eaten (in pounds)
The functionreturns one float.
- amount of fruit left (in pounds)
This implementation would go in the file library.cpp. You can assume the following code is already in library.cpp. You will need to add the code listed above.
#include
#include"library.h"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started