Advertisement
okanfeim

Untitled

May 4th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. #include <stdio.h>
  4. #include <cctype>
  5. void gallon (double num1);
  6. void liter (double num2);
  7. int main()
  8. {
  9. double liters, gallons;
  10. cout<<"Enter number of kilometers traveled:";
  11. cin>>liters;
  12. cout<<" Enter number of gallons of gas used: ";
  13. cin>>gallons;
  14. gallon(liters);
  15. liter(gallons);
  16. cout<<"\n Would you like to enter another?[y][n]";
  17. char ans;
  18. cin>>ans;
  19. if (ans=="Y")
  20. tolower(ans);
  21. else
  22. if (ans=="N")
  23. tolower(ans);
  24. while(ans=="y")
  25. {
  26. double liters, gallons;
  27. cout<<"Enter number of kilometers traveled:";
  28. cin>>liters;
  29. cout<<"\n Enter number of gallons of gas used: ";
  30. cin>>gallons;
  31. gallon(liters);
  32. liter(gallons);
  33. cout<<"Kilometers per gallon:"<<liters;
  34. cout<<"\n Kilometers per liter: "<<gallons;
  35. cout<<"\n Would you like to enter another?[1.yas][2.no]";
  36. int ans;
  37. cin>>ans;
  38. }
  39. void gallon(double num1)
  40. {
  41. num1=num1*0.264172051;
  42. cout<<"Kilometers per gallon:"<<num1;
  43. }
  44. void liter(double num2)
  45. {
  46. num2=num2*3.7854118;
  47. cout<<"\n Kilometers per liter: "<<num2;
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement