Question
Temperature Conversion In Unix/Linux 1: Write a program that allows the user to convert a temperature given in degrees from either Celsius to Fahrenheit or
Temperature Conversion In Unix/Linux
1: Write a program that allows the user to convert a temperature given in degrees from either Celsius to Fahrenheit or Fahrenheit to Celsius. Use the following formulas:
Degrees_ C = 5 ( Degrees_ F - 32) / 9
Degrees_ F = ( 9 ( Degrees_ C) / 5) + 32
Prompt the user to enter a temperature and either a C or c for Celsius or an F or f for Fahrenheit. Convert the temperature to Fahrenheit if Celsius is entered, or to Celsius if Fahrenheit is entered. Display the result in a readable format. If anything other than C, c, F, or f is entered, print an error message and stop. The input to this program is two lines. On the first line the user should enter C, c, F, or f. On the second line the user enters an integer.
Answer:
2: Write a program that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format:
mm/dd/yyyy
Note that there is no space in the above format. A date in this format must be entered in one line.
A valid month value mm must be from 1 to 12 ( January is 1). The day value dd must be from 1 to a value that is appropriate for the given month. September, April, June, and November each have 30 days. February has 28 days except for leap years when it has 29. The remaining months all have 31 days each. For the sake of simplicity assume the year is a leap year.
Note: It is an error if the user enters any other character in place of: /.
Answer:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started