Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<cstdlib>
- using std::cout;using std::endl;using std::cin;using std::string;using std::getline;
- //using std::hex;using std::dec;
- //program to calculate given weight in KG to POUNDS n vice versa
- //Users feel free to choose which conversion they want to calculate
- float kgtopound(float); // function declaration for KG to Pound Conversion
- float poundtokg(float); // For Pound to KG conversion
- //main body
- int main() {
- int x;
- float kg1,pound1,kg2,pound2;
- //User choice for the type of conversion
- cout<<"Enter -1 to get KG to POUND Conversion and -2 for Vice Versa: "<<endl;
- cin>>x;
- // KG to Pound Block
- if (x= -1){
- cout<<"Enter the weight in KG's Plz: "<<endl;
- cin>>kg1;
- pound1=kgtopound(kg1);
- cout<<"The desires result in pound is: "<<pound1<<endl;
- }
- //Pound To KG block
- else if (x = -2){
- cout<<"Enter the Weight in Pound Plz: "<<endl;
- cin>>pound2;
- kg2=poundtokg(pound2);
- cout<<"The desired result in KG is: "<<kg2<<endl;
- }
- else {
- cout<<"Not a valid value"<<endl;
- }
- return 0;
- }
- //Function for KG to POUND conversoin
- float kgtopound(float a) {
- float poundresult = 2.5*a;
- return poundresult;
- }
- //Function for Pound to KG conversion
- float poundtokg(float b) {
- float kgresult=b*3;
- return kgresult;
- }
- //ERROR I m always getting KG to pound coversion so how to fix the code.
Add Comment
Please, Sign In to add comment