Advertisement
Guest User

Temps

a guest
Oct 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. /* ____ __ __
  2. / / \\ / \\
  3. / / /
  4. / \\___/ \\___/
  5.  
  6. Date: 10/19/17
  7.  
  8. Name: Rebecca Lewis
  9.  
  10. Project Description: Hw #7 Problem 4;
  11. Inputs:
  12.  
  13. Outputs:
  14. */
  15. //*************************************************************
  16.  
  17. #include <iostream>
  18. #include <string>
  19. #include <cmath>
  20. #include <iomanip>
  21.  
  22. using namespace std; //introduces namespace std
  23.  
  24.  
  25. double Convert_Celsius (double);
  26. double Convert_Fahrenheit (double);
  27.  
  28. int main (void)
  29. {
  30. double C[21], F[21], K[21];
  31.  
  32. for(int i=0; i<21; i++)
  33. {
  34. C[i]=i*5;
  35. }
  36.  
  37. cout<<setw(14)<<" Celsius (C) " <<setw(17)<<"Fahrenheit (F) "<<"Kelvin (K)" <<endl;
  38.  
  39. for(int i=0; i<21;i++)
  40. {
  41. cout<<" "<<left<<setw(20)<<C[i];
  42. F[i]=Convert_Celsius(C[i]);
  43. cout<<fixed<<setprecision(1)<<setw(20)<<F[i];
  44. cout<<setw(6)<<Convert_Fahrenheit(F[i])<<endl;
  45. }
  46. return 0;
  47. }
  48.  
  49. //This function converts Celsius to Fahrenheit
  50. double Convert_Celsius (double Celsius)
  51. { double C_to_F;
  52. C_to_F= Celsius*(9.0/5)+32;
  53. return C_to_F;
  54. }
  55.  
  56. //This function converts Fahrenheit to Kelvin
  57. double Convert_Fahrenheit (double Fahrenheit)
  58. { double F_to_K;
  59. F_to_K= (Fahrenheit-32)*(5.0/9)+273.15;
  60. return F_to_K;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement