I'm trying to get an output for my weight_Fee
using double
, and I cannot seem to get the correct value. I have tried using float
, but I haven't been able to get that to work either.
My goal is to get an output value containing two decimal places as if I were to be calculating a cost, but I get 0.00 every time.
I'm new to C++, so if anyone can tell me what I'm doing wrong, it would be a big help. Thanks.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
double animal_Weight;
double weight_Fee = .5 * animal_Weight;
cout << "In rounded poundage, how much does your animal weigh? ";
cin >> animal_Weight;
cout << setprecision (2) << fixed << weight_Fee;
return 0;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…