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

It is important to consider effect of thermal expansion when building a structur

ID: 3729487 • Letter: I

Question

It is important to consider effect of thermal expansion when building a structure must withstand changes in temperature. For example, metals expand when exposed to hot temperatures and contract in colder temperatures. This is important because engineers must determine what stresses may cause a structure to fail. The change in length, delta-length, of a material (in centimeters) can be described by the following (mathematical) equation: delta-length = 100 × a × length × delta-temperature where length is the original length of the material when the change in temperature (deltatemperature) has a value of zero and a is the coefficient of expansion. The coefficient of expansion, a, for various metals is: Aluminum 2.13 × 10-5 Copper 1.70 × 10-5 Glass 8.50 × 10-6 Steel 1.20 × 10-5 Construct a program wherein the user enters values for length and the change in temperature. For each metal: If delta-length is positive then output the phrase For a change in temperature of xxx degrees C, yyy will expand by mmm centimeters. Replace mmm by delta-length by the calculated change in length to 2 decimal places, yyy by the actual name of the material and xxx by delta-temperature. If delta-length is negative then output the phrase For a change in temperature of xxx degrees C, yyy will contract by mmm centimeters. Replace xxx and yyy as described above, and mmm as described above BUT a positive value. If delta-length is zero then output the phrase For a change in temperature of xxx degrees C, yyy will remain the same. Replace xxx and yyy as described above. The following specifications and guidelines also apply: 1. Make sure that your project meets all of the requirements set forth. 2. 80% of your grade will be based on correctness, and 20% on innovation. 3. Be sure that it has your name in it. All work must be original and your own! No credit will be given for plagiarized work. 4. Even if you are not successful in completing the project, submit what you have as partial credit will be given for programs that would work if minor corrections in logic are made. 5. Any work that is submitted late is subject to the rules set forth in the syllabus!

Explanation / Answer

ScreenShot

---------------------------------------------------------------------------------------------------------------------------------------

Code:-

//Header file
#include<iostream>
#include<iomanip>
using namespace std;

//main method
int main()
{
   //variable declaration
   double Aluminum = 2.13 * 10 - 5, Copper= 1.70 * 10 - 5, Glass = 8.50 * 10 - 6, Steel = 1.20 * 10 - 5;
   double delta_lengthA, delta_lengthC, delta_lengthS, delta_lengthG, length, delta_temp;
   //Aske user inputs
   cout << "Enter the length of metal in cm = ";
   cin >> length;
   cout << "Enter the For a change in temperature in degree C = ";
   cin >> delta_temp;
   //calculate change in length of each given metals
   delta_lengthA= 100 * Aluminum*length*delta_temp;
   delta_lengthC = 100 * Copper*length*delta_temp;
   delta_lengthG = 100 * Glass*length*delta_temp;
   delta_lengthS = 100 * Steel*length*delta_temp;
   //set output precision
   cout.precision(2);
   //Check Aluminum length change ,positive=if condition,negative=else if condition,zero=else
   if (delta_lengthA > 0) {
       cout << "For a change in temperature of "<< delta_temp<< " degrees C , Aluminum"<< " will expand by "<< delta_lengthA<< " centimeters"<<endl;
   }
   else if (delta_lengthA < 0) {
       cout << "For a change in temperature of "<< delta_temp<< " degrees C , Aluminum"<<" will contract by "<< (delta_lengthA)*-1<<" centimeters" << endl;
   }
   else {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Aluminum" << " will remain same" << endl;
   }
   //Check Copper length change ,positive=if condition,negative=else if condition,zero=else
   if (delta_lengthC > 0) {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Copper" << " will expand by " << delta_lengthC << " centimeters" << endl;
   }
   else if (delta_lengthC < 0) {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Copper" << " will contract by " << (delta_lengthC)*-1 << " centimeters" << endl;
   }
   else {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Copper" << " will remain same" << endl;
   }
   //Check Glass length change ,positive=if condition,negative=else if condition,zero=else
   if (delta_lengthG > 0) {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Glass" << " will expand by " << delta_lengthG << " centimeters" << endl;
   }
   else if (delta_lengthG < 0) {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Glass" << " will contract by " << (delta_lengthG)*-1 << " centimeters" << endl;
   }
   else {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Glass" << " will remain same" << endl;
   }
  
   //Check Steel length change ,positive=if condition,negative=else if condition,zero=else
   if (delta_lengthS > 0) {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Steel" << " will expand by " << delta_lengthS << " centimeters" << endl;
   }
   else if (delta_lengthS < 0) {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Steel" << " will contract by " << (delta_lengthS)*-1 << " centimeters" << endl;
   }
   else {
       cout << "For a change in temperature of " << delta_temp << " degrees C , Steel" << " will remain same" << endl;
   }

    return 0;
}

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