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

Write a program that estimates the appropriate size for the collecting area of a

ID: 3689260 • Letter: W

Question

Write a program that estimates the appropriate size for the collecting area of a solar heated house. Determining collecting area size requires consideration of several factors, including the average number of heating degree days for the coldest month of a year (this is the product of the average difference between inside and outside temperatures and the number of days in the month), the heating requirement per square foot of floor space, the floor space, and the efficiency of the collection method. Your program will have to access (2) two data files.

File "hdd.txt" contains numbers representing the average heating degree days in the construction location for each of 12 months. File "solar.txt" contains the average solar insulation (rate at which solar radiation falls on one square foot of a given location) for each month. The first entry in each file represents data for January, the second is a data value for February, and so on.

The formula for approximating the desired collecting area (A) is

A = heat loss/energy resource

In turn, heat loss is computed as the product of the heating requirement, the floor space, and the heating degree days. The necessary energy resource is computed by multiplying the efficiency of the collection method by the average solar insulation per day and the number of days.

INPUT FILES:

hdd.txt

995         900        750         400         180         20           10           10           60           290         610         1051

solar.txt

500 750 1100 1490 1900 2100 2050 1550 1200 900 500 500

The following functions are mandatory and must be used in your program:

int daysinmonth(int);

int filemax(ifstream&, int&);

int nthItem(ifstream&, int);

SAMPLE RUN:

Enter 2 input files (heating_degree and then solar) : hdd.txt
solar.txt


What is the approximate heating requirement (Btu / degree day ft^2
of this type of construction?
=> 9


What % of solar insulation will be converted to usable heat?
=> 60


What is the floor space (ft^2)?
=> 1200


To replace heat loss of 11350800 Btu's in the coldest month (month 12)
with available solar insulation of 500 Btu / ft^2/day, and an efficiency of 60%, use solar collecting area of 1221 ft^2.

Explanation / Answer

#include <iostream>

#include <fstream>

using namespace std;

int main ()

{

ifstream fin("Solar.txt");

ifstream datast("hdd.txt");

if (fin.fail())

{

        cout << "The input file is not opened.";

        exit (1);

}

if (datast.fail())

{

        cout<< " The input file is not opened .";

        exit (1);

}

int heatingd, solain, heaingr, effcien, coldstmont, days;

double floorspace, heatloss, collectingarea, energyresource;

int fileMax(ifstream&, int& );

int daysinmonth(int );

int nthItem(ifstream&, int )

cout << "The approimate heating requirement (BTU/degree day ft^2) of this type of construction ";

cin >> heaingr;

cout << "The percent of solar nthItem will be converted to usable heat " ;

cin >> effcien;

cout << “The floor space (ft^2) ";

cin >> floorspace;

heatingd = fileMax("hdd.txt", coldstmont);

days = daysinmonth(coldstmont);

solain = nthItem("solar.txt", coldstmont);

heatloss = heaingr*floorspace*heatingd;

energyresource = effcien*0.01*solain*days;

collectingarea = heatloss/energyresource;

cout << "To replace heat loss of " << heatloss << " BTU's in the coldest month with available solar ";

cout << "nthItem of " << solain << " BTU/ft^2/day, and an effcien of " << effcien << "%, use " ;

cout << "a sloar collecting area of " << collectingarea << "ft^2 .";

return 0;

}

int fileMax(ifstream& datast, int& maxPos)

{

int large, next;

datast >> large;

maxPos = 1;

int ct = 2;

for (datast >> next; !datast.fail(); datast >> next)

{

if (next > large)

{

        large = next;

        maxPos = ct;

}

        ++ct;

}

return large;

}

int daysinmonth(int monthno)

{

        int ans;

switch (monthno)

        {

        case 2: ans=28;

               break;

        case 4:

       case 6:

      case 9: ans=30;

               break;

        default: ans=31;

        }

        return ans;

}

int nthItem(ifstream& fin, int monthno)

{

        int item;

       

        for (int i=1; i< monthno; i++)

               fin >> item;

       

        return item;

}

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