In C++ according to user input programmer able to find the final value is what double or int using this code.If 4/2 the answer is 2 Not 2.0. If 5/3 the answer is 1.66667 not 1.
float a;
float b;
cin >> a >> b;
float z = a / b;
cout << z << endl;
Simple thing is if user input is 2/4 the answer is 2 not 2.0. And if user input is 5/3 the answer is 1.66667 not 1 according to my c++ code. Can anybody do this same think in java Please?
Everybody know in calculator if we type 4/2 the answer is 2 not 2.0. And if we type 5/3 the answer is 1.66667 not 1. I just want to create something program like that i think now you understand me.