Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Find the radian measure of the central angle. 1. 2. 3. 4. 29 10

Answered: 1 week ago