The density of freshwater as a function of temperature (in Celsius) can be modeled: p= 5.53 x 10-8T - 8.50 x 10-672 + 6.56 x 10-5T. + 1.00 Write a function with structure function rho = density(T) that takes an array of temperatures T in Fahrenheit as an input and returns an array of corresponding densities as an output. An anonymous function that converts Fehrenheit to Celsius is provided.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
The density of freshwater as a function of temperature (in Celsius) can be modeled:
p = 5.53 x 10-873 – 8.50 x 10-67? + 6.56 x 10-5T. + 1.00
%3D
Write a function with structure
function rho density(T)
that takes an array of temperatures T in Fahrenheit as an input and returns an array of corresponding
densities as an output. An anonymous function that converts Fehrenheit to Celsius is provided.
Transcribed Image Text:The density of freshwater as a function of temperature (in Celsius) can be modeled: p = 5.53 x 10-873 – 8.50 x 10-67? + 6.56 x 10-5T. + 1.00 %3D Write a function with structure function rho density(T) that takes an array of temperatures T in Fahrenheit as an input and returns an array of corresponding densities as an output. An anonymous function that converts Fehrenheit to Celsius is provided.
Expert Solution
Step 1

As no programming language is mentioned, I have written the code in C++. A function to convert Fahrenheit to Celsius is written.

The program is 

#include <iostream>
#include<math.h>
using namespace std;
struct fahrenheit{
    float f[50];
};
struct rho{
    float r[50];
};
float celsius(float m)
{
    return ((float)5/(float)9)*(m-32);
}
rho density(fahrenheit a,int n)
{
   rho b;
    for(int i=0;i<n;i++)
    {
        a.f[i]=celsius(a.f[i]);
        b.r[i]=(5.53*pow(10,-8)*pow(a.f[i],3))-(8.50*pow(10,-6)*pow(a.f[i],2))+(6.56*pow(10,-5)*a.f[i])+1.00;
    }
    return b;
}
int main()
{
    int n,i;
    cout<<"Enter number of values: "<<endl;
    cin>>n;
    fahrenheit a;
    rho s;
    cout<<"Enter temperature values in fahrenheit "<<endl;
    for(i=0;i<n;i++)
    {
        cin>>a.f[i];
    }
    s=density(a,n);
    cout<<"The density values are: \nTemperature\tDensity\n";
    for(i=0;i<n;i++)
    {
        cout<<a.f[i]<<"\t\t"<<s.r[i]<<endl;;
    }
    return 0;
}

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education