1) Write two functions: a. main function (This is the stuff that makes up the ma
ID: 3629189 • Letter: 1
Question
1) Write two functions:a. main function (This is the stuff that makes up the main function)
i) Should ask the user for a numerator and a denominator
ii) Call a function that takes the numerator and denominator and returns the decimal value of the fraction
iii) displays the decimal
b. fraction_convertor (This is the stuff that makes up the fraction convertor function)
i. takes the numerator and denominator and converts it to decimal
ii. returns the decimal value
2) Write two functions
a. main function
i. Asks the user for someone’s weight in pounds
ii. calls a function that takes the weight and returns its equivalent in Kilograms
iii. Display the weight
b. pound convertor
i. takes the weight in pounds and converts it to kilogram
ii. returns the weight in kilograms
Explanation / Answer
please rate - thanks
CRAMSTER rule 1 question per post, but these are easy
#include <iostream>
#include <cmath>
using namespace std;
double fraction_converter(double,double);
int main()
{
double num,den;
cout<<"Enter the numerator: ";
cin>>num;
cout<<"Enter the denominator: ";
cin>>den;
cout<<num<<"/"<<den<<" = "<<fraction_converter(num,den)<<endl;
system("pause");
return 0;
}
double fraction_converter(double num,double den)
{return num/den;
}
-------------------------------
#include <iostream>
using namespace std;
double pound_converter(double);
int main()
{
double lb,kilo;
cout<<"Enter the weight in pounds: ";
cin>>lb;
cout<<lb<<"lbs"<<" = "<<pound_converter(lb)<<" kilos"<<endl;
system("pause");
return 0;
}
double pound_converter(double lb)
{return lb*.4536;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.