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...
Write a Java program (name it PasswordTest) that reads from the user a string input (representing...
Write a Java program (name it PasswordTest) that reads from the user a string input (representing a password) and determines whether the password is “Valid Password” or “Invalid Password”. A valid password has at least 7 characters and includes at least one lower-case letter, at least one upper-case letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order to...
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 a program that asks the user for a Fahrenheit temperature and calls a function name...
Write a program that asks the user for a Fahrenheit temperature and calls a function name Celsius that returns the temperature in Celsius of the Fahrenheit temperature sent to it. Your function will look similar to this: double celsius(double f) { double c; : : return c; }
In C Write a program that prompts the user to enter a Fahrenheit temperature calculate the...
In C Write a program that prompts the user to enter a Fahrenheit temperature calculate the corresponding temperature in Celsius and print it prompt the user if they want to do another temperature conversion if the user enters y, repeat 1), 2) and 3) if the user enters n, then print Bye and exit the program if the user enters any other character, ask the user to enter y or n only Note : c = (5.0/9.0)*(f-32.0) Sample output Enter...
Write a program that read the input from user and convert it to binary and hex...
Write a program that read the input from user and convert it to binary and hex in C language.
Program 3.5 - Conversion Program   - NOW using cin statements to gather input from user Concepts...
Program 3.5 - Conversion Program   - NOW using cin statements to gather input from user Concepts Covered:  Chapter 2 – cout ,   math, data types, Chapter 3 , gathering both numeric & string input from user Programs 2-21, 2-22, 2-23, 2-28 should help with math and programs 3.5, 3.17 and 3.19 should help you with the new concepts introduced with this program. Program Purpose:  To help you understand the concept of using both proper numeric variables and string variables. To give you practice...
1. Write a C++ code segment to read 50 temperature values in Fahrenheit and to convert...
1. Write a C++ code segment to read 50 temperature values in Fahrenheit and to convert them to Celsius. You convert a Fahrenheit temperature to Celsius by using the following formula: Celsius = 5.0 / 9 * (Fahrenheit - 32). 2.A client has purchased 20 products in a store. Write a C++ code segment to read the unit price and the number of items of each product and to compute and print the total price of all these products.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT