Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ____ __ __
- / / \\ / \\
- / / /
- / \\___/ \\___/
- Date: 10/19/17
- Name: Rebecca Lewis
- Project Description: Hw #7 Problem 4;
- Inputs:
- Outputs:
- */
- //*************************************************************
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <iomanip>
- using namespace std; //introduces namespace std
- double Convert_Celsius (double);
- double Convert_Fahrenheit (double);
- int main (void)
- {
- double C[21], F[21], K[21];
- for(int i=0; i<21; i++)
- {
- C[i]=i*5;
- }
- cout<<setw(14)<<" Celsius (C) " <<setw(17)<<"Fahrenheit (F) "<<"Kelvin (K)" <<endl;
- for(int i=0; i<21;i++)
- {
- cout<<" "<<left<<setw(20)<<C[i];
- F[i]=Convert_Celsius(C[i]);
- cout<<fixed<<setprecision(1)<<setw(20)<<F[i];
- cout<<setw(6)<<Convert_Fahrenheit(F[i])<<endl;
- }
- return 0;
- }
- //This function converts Celsius to Fahrenheit
- double Convert_Celsius (double Celsius)
- { double C_to_F;
- C_to_F= Celsius*(9.0/5)+32;
- return C_to_F;
- }
- //This function converts Fahrenheit to Kelvin
- double Convert_Fahrenheit (double Fahrenheit)
- { double F_to_K;
- F_to_K= (Fahrenheit-32)*(5.0/9)+273.15;
- return F_to_K;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement