Guest User

Untitled

a guest
Jul 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<cstdlib>
  4. using std::cout;using std::endl;using std::cin;using std::string;using std::getline;
  5. //using std::hex;using std::dec;
  6.  
  7. //program to calculate given weight in KG to POUNDS n vice versa
  8. //Users feel free to choose which conversion they want to calculate
  9.  
  10. float kgtopound(float); // function declaration for KG to Pound Conversion
  11. float poundtokg(float); // For Pound to KG conversion
  12.  
  13. //main body
  14. int main() {
  15. int x;
  16. float kg1,pound1,kg2,pound2;
  17.  
  18. //User choice for the type of conversion
  19. cout<<"Enter -1 to get KG to POUND Conversion and -2 for Vice Versa: "<<endl;
  20. cin>>x;
  21.  
  22. // KG to Pound Block
  23.  
  24. if (x= -1){
  25. cout<<"Enter the weight in KG's Plz: "<<endl;
  26. cin>>kg1;
  27. pound1=kgtopound(kg1);
  28. cout<<"The desires result in pound is: "<<pound1<<endl;
  29. }
  30.  
  31. //Pound To KG block
  32.  
  33. else if (x = -2){
  34. cout<<"Enter the Weight in Pound Plz: "<<endl;
  35. cin>>pound2;
  36. kg2=poundtokg(pound2);
  37. cout<<"The desired result in KG is: "<<kg2<<endl;
  38. }
  39.  
  40. else {
  41. cout<<"Not a valid value"<<endl;
  42. }
  43.  
  44. return 0;
  45. }
  46.  
  47. //Function for KG to POUND conversoin
  48. float kgtopound(float a) {
  49. float poundresult = 2.5*a;
  50. return poundresult;
  51. }
  52.  
  53. //Function for Pound to KG conversion
  54. float poundtokg(float b) {
  55. float kgresult=b*3;
  56. return kgresult;
  57. }
  58.  
  59. //ERROR I m always getting KG to pound coversion so how to fix the code.
Add Comment
Please, Sign In to add comment