Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a 100 level C++ class problem. if you please solve it using input and au

ID: 670889 • Letter: T

Question

This is a 100 level C++ class problem. if you please solve it using input and autput file stream and loops as simple as possible. and please make sure to be detailed as possible.

you can post the codes here and I will past it into my code blocks.

Thnaks

Program B-50 % There is no template provided for this program. You will create your own solution. The text file kennel.txt has information about the dogs that are boarding at Krusty's Kennel. Write a C++ program to calculate boarding bills for the dogs in the file. The total cost is determined by the weight of the dog, the number of days in the kennel, and whether or not the dog gets a bath. Bills should be printed to the output screen and to an output file. Cost per day is determined by the weight of the dog according to the following chart Weight

Explanation / Answer

Program:

#include <iostream>     // input and output functionality

#include <fstream>      //for input and output files

using namespace std;

double PerDayCost(int w);

double BathCost(int w);

int main()

{

               // open a file in read mode.

   ofstream outfile;           //output file stream variable

   ifstream infile;            //input file stream variable

   infile.open("kennel.txt");

   outfile.open("DogBills.txt");

   string dogName[10];

   int dogWeight[10];

   int daysInTheKennel[10];

   double costForBath,costPerDay,totalCost[10], costForStay[10], bathCharge[10];

   char bath[10];

   int numOfDogsGetBath=0;

   int i=0;

   cout<<endl<<"Dog Bills"<<endl<<"================";

   do

    {

               infile>>dogName[i];

    infile>>dogWeight[i];

    infile>>daysInTheKennel[i];

    infile>>bath[i];

   

    costPerDay=PerDayCost(dogWeight[i]);

               costForStay[i]=dogWeight[i]*costPerDay;

               costForBath=BathCost(dogWeight[i]);

              

               if(bath[i]=='y')

               {

               numOfDogsGetBath++;

               bathCharge[i]=costForBath;

               }

               else

               bathCharge[i]=0.0;

   totalCost[i]=costForStay[i]+bathCharge[i];

   cout<<endl<<endl<<"==================================================================";

   cout<<endl<<dogName[i]<<" stayed "<<daysInTheKennel[i]<<" days;";

   cout<<endl<<"Bill for "<<dogName[i];

   cout<<endl<<"$ "<<costForStay[i]<<" "<<daysInTheKennel[i]<<" days * "<<costPerDay<<" per day";

   cout<<endl<<"$ "<<bathCharge[i]<<" "<<" bath charge";

   cout<<endl<<"------";

   cout<<endl<<"$ "<<totalCost[i];

   cout<<endl<<"==================================================================";

   outfile<<endl<<endl<<"==================================================================";

   outfile<<endl<<dogName[i]<<" stayed "<<daysInTheKennel[i]<<" days;";

   outfile<<endl<<"Bill for "<<dogName[i];

   outfile<<endl<<"$ "<<costForStay[i]<<" "<<daysInTheKennel[i]<<" days * "<<costPerDay<<" per day";

   outfile<<endl<<"$ "<<bathCharge[i]<<" "<<" bath charge";

   outfile<<endl<<"------";

   outfile<<endl<<"$ "<<totalCost[i];

   outfile<<endl<<"==================================================================";

   i++;

   }while(!infile.eof());

   cout<<endl<<"There were "<<i<<" dogs are processed";

   cout<<endl<<"There were "<<numOfDogsGetBath<<" who received baths";

   infile.close();

   outfile.close();

   return 0;

}

   double BathCost(int w)

    {

               double costForBath;

               if(w< 20)

                              costForBath=12.00;

               else if(w>=20 && w<50)

                              costForBath=18.00;

               else if(w>=50)

                              costForBath=25.00;

                              return costForBath;

   }

  

   double PerDayCost(int w)

    {

               double costPerDay;

    if(w< 10)

                              costPerDay=10.00;

               else if(w>=10 && w<30)

                              costPerDay=15.00;

               else if(w>=30 && w<50)

                              costPerDay=20.00;

               else if(w>=50)

                              costPerDay=28.00;          

                              return costPerDay;

               }

Inputfile: kennel.txt

Ozzie     50           5             y

Lola       70           5             y

Goldie   10           8             n

Leroy     30           1             y

Screen Output & OutFile output: DogBills.txt

Dog Bills

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

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

Ozzie stayed 5 days;

Bill for Ozzie

$ 1400 5 days * 28 per day

$ 25     bath charge

------

$ 1425

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

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

Lola stayed 5 days;

Bill for Lola

$ 1960 5 days * 28 per day

$ 25     bath charge

------

$ 1985

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

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

Goldie stayed 8 days;

Bill for Goldie

$ 150   8 days * 15 per day

$ 0      bath charge

------

$ 150

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

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

Leroy stayed 1 days;

Bill for Leroy

$ 600   1 days * 20 per day

$ 18     bath charge

------

$ 618

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

There were 4 dogs are processed

There were 3 who received baths

--------------------------------

Process exited after 0.1828 seconds with return value 0

Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote