Question

In: Computer Science

*In C++ language please* Create a table that converts temperatures from Celsius to Fahrenheit Ask the...

*In C++ language please*

Create a table that converts temperatures from Celsius to Fahrenheit

Ask the user if they would like to know today's temperatures

  • When "yes":
    • Ask or their name -Generate a random number: use the length of their name (nameLngth) to set the seed
      • Use the length of their name (nameLngth) as the starting point, and 99 as the ending point for a range of Celsius temperatures
      • Output the range of Celsius temperatures alongside the Fahrenheit temperature conversions in a table
  • When "no":
    • Output "Goodbye userName "

Hint: Run in submit mode to see the desired outputs before getting started

Celsius to Fahrenheit : Fahrenheit = Celsius *180.0 /100 + 32

Also based on the new Fahrenheit temperature output the appropriate statement below:

  • When the number is less than 55: "carry a hat and gloves"
  • When the number is less than 75: "carry a jacket"
  • When the number is less than 100: "shorts it is"

Solutions

Expert Solution

Please find the code , output below.

#include <iostream>
#include<cstdlib>
using namespace std;

int main()
{   
string ans="yes",name;
int nameLngth;
double Fahrenheit ,Celsius;
cout<<"Would you like to know today's temperatures ? ";
cin>>ans;
while(1){
if (ans=="yes"){
cout<<"Enter your name : ";
cin>>name;
nameLngth = name.length();
srand(nameLngth);
Celsius = rand() % 99 + nameLngth;
Fahrenheit= Celsius *180.0 /100 + 32;
cout<< "Today's temparature is "<<endl;
cout << "Celsius"<<"\t\t"<<"Fahrenheit"<<endl;
cout << "---------------------------------"<<endl;
cout << Celsius<<"\t\t\t"<<Fahrenheit<<endl;

if (Fahrenheit<55){
cout<< "carry a hat and gloves\n";
}   
else if (Fahrenheit>=55 && Fahrenheit<75){
cout<< "carry a jacket\n";
}
else if (Fahrenheit>=75 && Fahrenheit<100){
cout<< "shorts it is\n";
}
}
else{
cout<< "Goodbye "<<name;
exit(0);
}
cout<<"Would you like to know today's temperatures ? ";
cin>>ans;
}
return 0;
}

OUTPUT :


Related Solutions

Write a program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton...
Write a program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton (Links to an external site.) temperatures. The formula for the conversion from Celsius to Fahrenheit is : F=9/5*C+32 F is the Fahrenheit temperature, and C is the Celsius temperature. The formula for the conversion from Celsius to Newton is C = 100/33*N N is the Newton Temperature and C is the Celsius temperature Your C++ program should prompt the user for a lower value...
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents....
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents.  The formula for converting a temperature from Celsius to Fahrenheit is F = 9/ 5 C + 32 where F → Fahrenheit temperature C → Celsius temperature.  Allow the user to enter the range of temperatures in Celsius to be converted into Fahrenheit.  Your program must use a loop to display the values of the temperature conversions (see sample output). Sample...
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.
At what temperatures values are the following scales the same? (a) The Fahrenheit and the Celsius   ...
At what temperatures values are the following scales the same? (a) The Fahrenheit and the Celsius    (b) The Celsius and the Kelvin     (c) The Fahrenheit and the Kelvin  
Create a table in C of conversion from Celsius to Rankin. Allow the user to enter...
Create a table in C of conversion from Celsius to Rankin. Allow the user to enter the starting temperature and increment between lines. Print 25 lines in the table. Rankin = 9/5(Celsius + 273.15)
Write a javascript program according to the follow requirements: Create a function that converts Fahrenheit to...
Write a javascript program according to the follow requirements: Create a function that converts Fahrenheit to Celsius. It takes a single argument which represents degrees in Fahrenheit. It converts it and returns the degrees in Celsius. Create another function that converts Celsius to Fahrenheit. It takes a argument in Celsius and returns the degrees in Fahrenheit. Implement the function convert(isFtoC, from, to) below. It takes the following three arguments: isFtoC: a boolean that is true if degrees must be converted...
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
Q#3 Write a C++ program to read 10 temperatures in Celsius and to store the temperatures...
Q#3 Write a C++ program to read 10 temperatures in Celsius and to store the temperatures in an array of integers, then it should convert the temperatures to Fahrenheit and store the new values rounded to the nearest integer in another array . The program should display both temperatures in a table form.    F = 9/5 x C + 32 where F is temp in Fahrenheit and C temperature in Celsius
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin...
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....
**********Java language************ 1-      (Conversions between Celsius and Fahrenheit) Write a class that contains the following two methods:...
**********Java language************ 1-      (Conversions between Celsius and Fahrenheit) Write a class that contains the following two methods: /** Convert from Celsius to Fahrenheit */ public static double celsiusToFahrenheit(double celsius) /** Convert from Fahrenheit to Celsius */ public static double fahrenheitToCelsius(double fahrenheit) The formula for the conversion is: Celsius = (5.0 / 9) * (Fahrenheit – 32) Fahrenheit = (9.0 / 5) * Celsius + 32 Program output should be like: If you want to convert from Fahrenheit To Celsius press 0...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT