Answer to Question #167539 in C++ for Sean

Question #167539

The fact that most metals expand when heated and contract when cooled has serious implications when the dimensions of a piece of laboratory equipment are critical to an experiment. A typical aluminum bar that is w cm wide at 70 degrees Fahrenheit will be


x =w + (t – 70) x 10-4


cm wide at a nearby temperature t. Write a program that prompts the user for the standard width of a bar at 70 degrees Fahrenheit and for a tolerance for width variation. Then display a table like the one below indicating the bar’s width at temperatures from 60 degrees to 85 degrees in one degree intervals and marking with a star (*) the temperatures at which the bar’s width is within the tolerance.


1
Expert's answer
2021-02-28T07:03:35-0500
#include <iostream>


using namespace std;


int main()
{
    cout << "Enter, please, the standard width of bar: ";
    int w;
    cin >> w;
    float R;
    cout << "Enter, please, the tolerance: ";
    cin >> R;
    int t;
    double x;
    for(t = 60; t < 86; ++t)
    {
        x = w + ((t - 70) * (0.0001));
        if(x > w + R || x < w - R)
            cout << "(*)The width of bar in temperature = " << t << " is " << x << endl;
            else
                cout << "The width of bar in temperature = " << t << " is " << x << endl;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS