The Green Tree Service Company offers the following services to its customers:
* tree planting - $35 for a small tree, $100 for a medium tree, $250 for a large tree
* tree removal - $150 per tree
* tree trimming - $50 per hour
* stump removal - $75 for stumps with a diameter of 10 inches or less, $10 per inch for stumps with a diameter greater than 10 inches
Write a C++ program that will read a series of data values from a file using Linux redirection. The data values will represent a group of jobs that the Green Tree Service Company has completed. The program will compute the amount billed for each job and display a nicely formatted report that lists each job, the billed amounts, and a total due. Use named constants for fixed values (minimum of 5).
Input
The input file will contain data for several jobs. Each job will have a Job # which will be an integer. After the Job #, the work performed will be indicated using the following codes:
* P, p = tree planting, this code will be followed by an integer indicating how many trees were planted and one character code (S,s,M,m,L,l) for the size of each tree planted
* R, r = tree removal, this code will be followed by an integer indicating how many trees were removed
* T, t = tree trimming, this code will be followed by a floating point value indicating how many hours were spent trimming
* S, s = stump removal, this code will be followed by a series of integers that represent the diameters of the stumps removed, 0 will serve as a sentinel to signal the end of the stump data
* Q, q = end of job details
Here is a sample file:
123
P 3 M m S
t 2.5
Q
45
S 5 12 3 10 7 16 0
r 4
p 1 L
q
Here is an explanation of the sample file:
123 Job# 123
P 3 M m S planted 3 trees, 2 medium, 1 small
t 2.5 trimmed trees for 2.5 hours
Q end of job# 123
45 Job# 45
S 5 12 3 10 7 16 0 removed 6 stumps with diameters of 5, 12, 3,
10, 7, 16 inches
r 4 removed 4 trees
p 1 L planted 1 large tree
Q end of job# 45
The program must keep processing data until the end of file is encountered.
Output
Display your name, section #, and assignment #. Then output a nicely formatted report with 6 columns labeled as shown in the example below. Job #s should be left justified and will have a maximum of 6 digits. The values displayed in each of the remaining columns will be right justified. Assume the largest $ amount to be displayed will be $100,000.00. Include $ signs and 2 digits to the right of the decimal for all monetary amounts. Display the total amount billed on the last line of the report (do NOT total any other columns).
* No invalid data will be included in the file.
* The data for each job will end with the Q or q code.
* For each job, there will be at most 1 set of input values per type of service.
* All service codes may be entered as capital or lower case letters
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int data;
char q;
char Q;
double time;
double diameter;
double M = 100;// medium tree plant
double m = 100;// medium tree plant
double S = 35;// small tree plant
double s = 35;// small tree plant
double L = 100;// large tree plant
double l = 100;// large tree plant
double t = time * 50; // tree trimming
double r = 150; // tree removal
double St = 75 + (10*diameter); // stump removal