Question

Using your Assignment 1 file, use the setw, showpoint, setprecision and the left and right alignment...

Using your Assignment 1 file, use the setw, showpoint, setprecision and the left and right alignment manipulators to format your output .

(Assignment 1 = Tom and Jerry opened a new lawn service. They provide three types of services; mowing, fertilizing, and planting trees. The cost of mowing is $35.00 per 5,000 square yards, fertilizing is $30.00 re application, and planting a tree is $50.00. Write an algorithm that prompts the user to enter the area of the lawn, the number of fertilizing applications, and the number of trees to be planted. The algorithm then determines the billing amount. Assume the user orders all three services.)(Ch1. #18)

We are using the textbook C++ Programming, 8th Edition, from Problem Analysis to Program Design. We were only ever asked to provide an algorithm for assignment 1, so I'm not sure how implement setw, showpoint, or setprecision.

This is my submission for assignment 1.
/*
1: Get area in sq. yards
2: Get num. of trees needed
3: Get num. of fertilizer applications
4: Get cost to mow.
   CostOfMowing = (35.0 / 5000.0) * AreaOfLawn
5: Get cost of fertilizing area.
   CostOfFertilizing = 30.0 * NumOfApplications
6: Get cost of trees planted.
   CostOfTrees = 50.0 * NumOfTrees
7: Get bill total.
   BillAmount = CostOfMowing + CostOfFertilizing + CostOfPlanting
  
   */

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please rate the answer.

Thank You!


===========================================================================

#include<iostream>
#include<iomanip>

using namespace std;

int main(){


   double area;
   int trees_count =0, fertilizers=0;
   const double MOWING_COST = 35.00/5000;
   const double FERTILIZING_COST = 30.0;
   const double PLANTING_COST=50.00;
  
   cout<<"Enter area in square yards: "; cin>>area;
   cout<<"Enter number of trees to be planted: "; cin>>trees_count;
   cout<<"Enter number of fertilizer applications: "; cin>>fertilizers;
  
   double total_cost = area*MOWING_COST + trees_count*PLANTING_COST + fertilizers*FERTILIZING_COST;
  
   cout<<endl;
   cout<<setw(20)<<left<<"MOWING COST: "<<"$"<<setw(10)<<right<<fixed<<showpoint<<setprecision(2)<<area*MOWING_COST<<endl;
   cout<<setw(20)<<left<<"PLANTING COST: "<<"$"<<setw(10)<<right<<fixed<<showpoint<<setprecision(2)<<total_cost<<endl;
   cout<<setw(20)<<left<<"FERTILIZING COST: "<<"$"<<setw(10)<<right<<fixed<<showpoint<<setprecision(2)<<total_cost<<endl;
   cout<<"================================\n";
   cout<<setw(20)<<left<<"TOTAL COST: "<<"$"<<setw(10)<<right<<fixed<<showpoint<<setprecision(2)<<total_cost<<endl;
   cout<<"================================\n";

   return 0;
}

=========================================================================

Add a comment
Know the answer?
Add Answer to:
Using your Assignment 1 file, use the setw, showpoint, setprecision and the left and right alignment...
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
  • C++ Need help with this code. Can't use "using namespace std;" Control break report Objectives Read...

    C++ Need help with this code. Can't use "using namespace std;" Control break report Objectives Read data from a text file Write data to a text file Correctly end a file input loop when end of file is reached Process control breaks correctly Calculate sums for grouping of input data Implement an algorithm Format output data on a report neatly Test and debug a program Overview This assignment involves the creation of a level break report. The data file provided...

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