Question

Please solve this coding in C++ language. Create a library with the following functions (prototypes and...

Please solve this coding in C++ language.

Create a library with the following functions (prototypes and descriptions are given):

- double energyToHeatWater(double mass, double deltaT); // returns the heat, in joules, required to heat “mass” (in grams) of liquid water at atmospheric pressure by “deltaT” degrees C. The function should limit the maximum deltaT to 100C as a larger value is not possible for liquid water at atmospheric pressure.

- double energyToBoilWater(double mass); // returns the heat, in joules, required to boil “mass” (in grams) of liquid water at atmospheric pressure.

- double timeToHeatWater(double mass, double deltaT, double powerIn); // returns the time, in seconds, required to heat “mass” (in grams) of liquid water at atmospheric pressure by “deltaT” degrees C when applying "powerIn" watts of power. The function should limit the maximum deltaT to 100C as a larger value is not possible for liquid water at atmospheric pressure.

- double timeToBoilWater(double mass, double powerIn); // returns the time, in seconds, required to boil “mass” (in grams) of liquid water at atmospheric pressure when applying "powerIn" watts of power.

Once your library is created, write a program to make use of it. The program models a pot of water on the stovetop. You ran an experiment to determine how much power is generated by the burner on the stove. In this experiment, you measured the time required to boil off the contents of the pot. You ran four trials of the experiment, with different starting water mass and temperature. These trials generated the following data (read as mass in grams, starting temperature in degrees C, and time to boil off in seconds):

1000     30   2090
1200     50   2312
1500     10   3186
500     25   1020

Set up a text file with this data. (Alternately, fork from https://onlinegdb.com/HyYD9KhSH (Links to an external site.) .) In the program, read each row of data from the file, then calculate the total energy required to boil off the contents, and from that the power. Use the “timeTo” functions (to check the value of power) for each of the trials and verify that the time returned is the same time that was measured in the experiment. Determine the average power from all four trials. Save the results to a file:

1000     30   2090 POWER CHECKTIME
1200     50   2312 POWER CHECKTIME
1500     10   3186 POWER CHECKTIME
500     25   1020 POWER CHECKTIME
AveragePower

Equations:

For liquid water: Q=m*Cp*deltaT; m in grams, C =4.2 KJ/KG-K; deltaT in K
To boil water at saturation: Q=m*deltaHVap, m in grams; deltaHVap =2256 KJ/KG

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

ANSWERS:

Make two separate files, in one file take four methods and save this file with .h extension and include this header file in another file.

Step 1: create, a method for calculation of conversion energy into heat water by using formula which returns the double type value.

Formula: mass*C*deltaT

Step 2: create, a method for calculation of energy to Boil water by using formula which returns the double type value.

Formula: mass*Watt

step 3: create, a method for calculation of time to heat water by using formula which returns the double type value.

Formula: (C*mass*deltaTT)/powerln

step 4: create, a method for calculation of time to Boil water by using formula which returns the double type value.

Formula: mass*powerIn

Another File Work:

Step 5: calculate energy and Time and put in a formula for calculation of power.

Formula: power=energy/time.

Step 6: Finally calculate average power of all user inputs.

PROGRAM:

#include<iostream>// include header file
#define C 4.2
#define Watt 1600
double energyToHeatWater(double mass, double deltaT) {
if(deltaT > 100) { //checking for condition, whether delta T is less than or equal to 100 or not
std::cout<<"try again deltaT must be less than or equals to 100 \n";
return 0;
}
return (mass*C*deltaT);
}

double energyToBoilWater(double mass) {
return (mass*Watt);
}

double timeToHeatWater(double mass, double deltaTT, double powerln) {
if(deltaTT > 100) {
std::cout<<"try again deltaT must be less than or equals to 100 \n";
return 0;
}
return ((C*mass*deltaTT)/powerln);
}

double timeToBoilWater(double mass, double powerIn) {
return (mass*powerIn);
}

/* Including Temperature.h in Cal_Temp.cpp file*/

#include "Temperature.h"//including above file
#include<iostream>

int main() {
int n=0;
double a, b, c, avg_power = 0.0;
while(n !=4) {
std::cin>>a>>b>>c;
double e1 = energyToHeatWater(a, b);
double e2 = energyToBoilWater(a);
double t1 = timeToHeatWater(a, b, c);
double t2 = timeToBoilWater(a, c);
double p = ((e1+e2)/(t1+t2)*1000); //to convert kilowatt into watt multiply by 1000
avg_power += p; // calculating average power
std::cout<<" "<<a<<" "<<b<<" "<<c<<" "<<p<<" Checked\n";
n++;
}
std::cout<<"Average Power is: "<<avg_power<<"\n"; // print average power value
return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Please solve this coding in C++ language. Create a library with the following functions (prototypes and...
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
  • PartA: Penny-→ Cu2+(aq) Make sure it is dated prior to 1982. Record mass to nearest 0.001 I. Weig...

    PartA: Penny-→ Cu2+(aq) Make sure it is dated prior to 1982. Record mass to nearest 0.001 I. Weigh a copper penny. grams. 2. Place 450 mL of distilled water in a clean 600-mL beaker. Place the beaker on a hotplate and heat until the water boils. Do not wait for the water to boil now, but proceed with the rest of the experiment. You will need this water for rinsing in step C3. CAUTION. You will generate poison°แs nitrogen dioxide...

  • 1. Which of the following are the sites within the human body where carbon dioxide and...

    1. Which of the following are the sites within the human body where carbon dioxide and oxygen are exchanged? A. Alveoli B. Arteries C. Synapses D. Venules 2. Which of the following describes the most important reason for repeating an experimental investigation? A. To verify the validity of the original findings B. To expand upon the original investigation C. To manipulate the independent variable D. To attempt to disprove the hypothesis 3. Lithium has an atomic number of 3 and...

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