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

Curious how to code this in C++ Programming Challenges 22 22. Freezing and Boili

ID: 3747121 • Letter: C

Question

Curious how to code this in C++

Programming Challenges 22 22. Freezing and Boiling Points The following table lists the freezing and boiling points of several substances. Write a program that asks the user to enter a temperature then shows all the subs will freeze at that temperature, and all that will boil at that temperature. For the user enters 20, the program should report that water will freeze and oxygen will boil at that temperature tances example, if Substance Boiling Point (°F) Freezing Point (°F) 173 38 362 32 172 676 306 212 Ethyl alcohol Mercury Oxygen Water

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

    // store the names of elements

    string element[] = { "Ethyl Alcohol" , "Mercury" , "Oxygen" , "Water" };

   

    // store the boiling points

    double boiling[] = { -173 , -38 , -362 , 32 };

   

    // store the freezing points

    double freezing[] = { 172 , 676 , -306 , 212 };

   

    double temp;

   

    cout<<"Enter the temperature : ";

    cin>>temp;

   

    int i;

   

    cout<<"Elements that will boil : ";

   

    // traverse throught eh arrays to check which elements will boil

    for( i = 0 ; i < 4 ; i++ )

    {

        // if the boiling point of current element is less than equal to current temperature

        if( boiling[i] >= temp )

            cout<<element[i]<<" ";

    }

   

    cout<<" Elements that will freeze : ";

   

    // traverse throught eh arrays to check which elements will boil

    for( i = 0 ; i < 4 ; i++ )

    {

        // if the freezing point of current element is greater than equal to current temperature

        if( freezing[i] <= temp )

            cout<<element[i]<<" ";

    }

   

    return 0;

}

Sample Output

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