Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- #include <stdio.h>
- #include <cctype>
- void gallon (double num1);
- void liter (double num2);
- int main()
- {
- double liters, gallons;
- cout<<"Enter number of kilometers traveled:";
- cin>>liters;
- cout<<" Enter number of gallons of gas used: ";
- cin>>gallons;
- gallon(liters);
- liter(gallons);
- cout<<"\n Would you like to enter another?[y][n]";
- char ans;
- cin>>ans;
- if (ans=="Y")
- tolower(ans);
- else
- if (ans=="N")
- tolower(ans);
- while(ans=="y")
- {
- double liters, gallons;
- cout<<"Enter number of kilometers traveled:";
- cin>>liters;
- cout<<"\n Enter number of gallons of gas used: ";
- cin>>gallons;
- gallon(liters);
- liter(gallons);
- cout<<"Kilometers per gallon:"<<liters;
- cout<<"\n Kilometers per liter: "<<gallons;
- cout<<"\n Would you like to enter another?[1.yas][2.no]";
- int ans;
- cin>>ans;
- }
- void gallon(double num1)
- {
- num1=num1*0.264172051;
- cout<<"Kilometers per gallon:"<<num1;
- }
- void liter(double num2)
- {
- num2=num2*3.7854118;
- cout<<"\n Kilometers per liter: "<<num2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement