Question

In: Computer Science

Write a program read in data from the standard input stream (cin) representing temperature in Fahrenheit....

Write a program read in data from the standard input stream (cin) representing temperature in Fahrenheit. The program will then convert the values into Kelvin (using 5/9 (Fº-32) to convert to Celsius and a difference of 273.15 between Celsius and Kelvin) and print out the new total value.

Convert temperature in Fahrenheit to Kelvin :

Enter temperature in Fahrenheit: 80.33

The temperature in Kelvin is: 300

Write a second program which then does the reverse conversion (using a difference of 273.15 between Celsius and Kelvin, and 9/5 (Cº+32) to convert from Celsius).A typical run and the expected output of your program would look like this:

Convert temperature in Fahrenheit to Kelvin :

Enter temperature in Kelvin: 300

The temperature in Fahrenheit: 80.33

Solutions

Expert Solution

Solution:

First Program:

#include <iostream>

using namespace std;

int main()

{

//declare variables

float kelvin, fahrenheit;

    cout << "Convert temperature in Fahrenheit to Kelvin:\n";

cout << "Enter temperature in Fahrenheit: ";

//read in data from the standard input stream (cin)

cin >> fahrenheit;

//convert temperature into kelvin

kelvin = (5.0 / 9) * (fahrenheit - 32) + 273.15;

//print output

cout << "The temperature in Kelvin is: " << kelvin << endl;

return 0;

}

Output:

Second Program:

#include <iostream>

using namespace std;

int main()

{

//declare variables

float kelvin, fahrenheit;

    cout << "Convert temperature in kelvin to Fahrenheit:\n";

cout << "Enter temperature in Kelvin: ";

//read in data from the standard input stream (cin)

cin >> kelvin;

//convert temperature into kelvin

fahrenheit = (kelvin - 273.15 ) * 9.0 / 5 + 32;

//print output

cout << "The temperature in Fahrenheit is: " << fahrenheit << endl;

return 0;

}

Output:

Please give thumbsup, if you like it. Thanks.


Related Solutions

Write a function in bash that takes an input temperature (Celsius or Fahrenheit) from the user...
Write a function in bash that takes an input temperature (Celsius or Fahrenheit) from the user converts that temperature Celsius to Fahrenheit, Fahrenheit to Celsius, Celsius to Kelvin and Fahrenheit to Kelvin
****USING BASH**** Write a function that takes an input temperature (Celsius or Fahrenheit) from the user...
****USING BASH**** Write a function that takes an input temperature (Celsius or Fahrenheit) from the user converts that temperature Celsius to Fahrenheit, Fahrenheit to Celsius, Celsius to Kelvin and Fahrenheit to Kelvin.
Write a program that reads in a continuous stream of strings representing a line of CSV...
Write a program that reads in a continuous stream of strings representing a line of CSV data in the format "NAME,AGE,EMAIL,DOB". Implement a function check_csv which verifies that each input string matches this format by ensuring that: • There are 4 tokens in the string corresponding to the 4 properties above. • The second token MUST be a number. • The fourth token should be in the format MM-DD-YYYY (hint: tokenize this as well). The function should return 0 if...
Program this using C please The program will read from standard input two things - a...
Program this using C please The program will read from standard input two things - a string str1 on the first line of stdin (this string may be an empty string) - a string str2 on the second line of stdin (this string may be an empty string) Note that stdin does not end with '\n'. The program will output a string that is the concatenation of string str1 and string str2 such that any lower-case alphabet character (a-z) will...
write this program in c++ using iostream library.( cin>>n; cin>> arr[n] and so on) Write a...
write this program in c++ using iostream library.( cin>>n; cin>> arr[n] and so on) Write a function that converts an array so that in the first half settled with elements from odd positions, and in the second half - with elements from the even positions.Positions are counted from the first index.The program have to use pointer. example: input: 7 1 2 3 4 5 6 7 output: 1 3 5 7 2 4 6 8
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The...
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The table should include rows for all temperatures between 0 and 100 degrees Celsius that are multiples of 10 degrees Celsius. Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit can be found on the internet. Python 3
Instructions Write a program in C# that converts a temperature given in Fahrenheit to Celsius. Allow...
Instructions Write a program in C# that converts a temperature given in Fahrenheit to Celsius. Allow the user to enter values for the original Fahrenheit value. Display the original temperature and the formatted converted value. Use appropriate value returning methods for entering (input), calculating, and outputting results.
Write a program that takes two sets ’A’ and ’B’ as input read from the file...
Write a program that takes two sets ’A’ and ’B’ as input read from the file prog1 input.txt. The first line of the file corresponds to the set ’A’ and the second line is the set ’B’. Every element of each set is a character, and the characters are separated by space. Implement algorithms for the following operations on the sets. Each of these algorithms must be in separate methods or subroutines. The output should be written in the file...
Write a program that takes three sets ’A’, ’B’, ’C’ as input read from the file...
Write a program that takes three sets ’A’, ’B’, ’C’ as input read from the file prog2 input.txt. The first line of the file corresponds to the set ’A’, the second line is the set ’B’, and the third line is the set ’C’. Every element of each set is a character, and the characters are separated by space. Implement algorithms for the following operations on the sets. Each of these algorithms must be in separate methods or subroutines. The...
Write a short main program that reads an integer n from standard input and prints (to...
Write a short main program that reads an integer n from standard input and prints (to standard output) n lines of * characters. The number of *’s per line should double each time, starting with 1. E.g., if n = 5, the output should be as follows: * ** **** ******** ****************
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT