You should really specify what language you're using when you're asking a programming related question. I did modify the input slightly, to use xc or xf, where x is the given temperature.
Here it is in Python:
import re
def to_celsius(fahrenheit):
return (fahrenheit - 32) / 1.8
def to_fahrenheit(celcius):
return celcius * 1.8 + 32
while True:
_in = input().lower()
if re.match(r'\d+(.\d+)?c', _in):
print(f'{_in} is {to_fahrenheit(float(_in.replace("c", "")))}f')
elif re.match(r'\d+(.\d+)?f', _in):
print(f'{_in} is {to_celsius(float(_in.replace("f", "")))}c')
else:
print('Invalid input.')