Implement the following functi

Implement the following function:a. float temp(float t, char ch) – this function takes temperature‘t’ and unit oftemperature ‘ch’ as parameter. The variable ‘ch’ will be either for c depending onwhether the temperature in variable ‘t’ is in Fahrenheit orCelsius. The functionreturns the converted temperature to the main method.Call the above function in the main method. Initialize temperatureand unit oftemperature from the user and pass them as parameter to the abovefunction. Theconverted temperature should be displayed in the main method.

Hi teacher can you please give me solution in c++& python

Answer:

The C++ code is as under

########################

#include <iostream>

using namespace std;

float temp(float t, char ch) {if (ch == ‘C’ || ch == ‘c’) {return t*1.8;}else if (ch == ‘F’|| ch == ‘f’) {return t/1.8;}else {float t;char ch;cout<<“Please input temperature, only numbers”;cin>>t;cout<<“Please input C for celcius and F forFahrenheit”;cin>>ch;cout<<temp(t,ch);  }}

int main(){   float t;char ch;cout<<“Please input temperature, only numbers”;cin>>t;cout<<“Please input C for celcius and F forFahrenheit”;cin>>ch;if(ch == ‘F’|| ‘f’){cout<<temp(t,ch);cout<<“Converted to Celcius”;}else if(ch == ‘C’|| ‘c’){cout<<temp(t,ch);cout<<“Converted to F”;}  

return 0;}

##########################

the python code is as under

##################

def temp(t,ch):if(ch == ‘C’ || ch == ‘c’):return t*1.8else if(ch == ‘F’ || ch == ‘f’):return t/1.8else:return temp(input(‘Please input temperature, only numbers’),input(‘Please input C for celcius and F for Fahrenheit’)

if __name__==”__main__”:t = input(‘Please input temperature, only numbers’);x = input(‘Please input C for celcius and F for Fahrenheit’);if(x==”C”||x==”c”):print(temp(t,x ))print(“Converted to F”)else:print(temp(t,x ))print(“Converted to C”)  


 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.