error C2296: '%' : illegal,left operand has type 'double'
Code:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
const int OUNCES_PER_POUND = 16;
const double POUNDS_PER_KILOGRAM = 2.2;
int main()
{
int Pounds;
int Ounces;
double Kilograms;
double totalPounds;
double totalOunces;
ifstream fin;
ofstream fout;
fin.open("inData.txt");
fout.open("outData.txt");
fin >> Kilograms;
totalPounds = static_cast<double>(Kilograms * POUNDS_PER_KILOGRAM);
totalOunces = static_cast<double>(Pounds * OUNCES_PER_POUND);
Pounds = static_cast<int>(totalOunces / OUNCES_PER_POUND + 0.5);
Ounces = static_cast<int>(totalPounds % OUNCES_PER_POUND);
fout << Pounds << "\nPounds";
fout << Ounces << "\nOunces";
fin.close();
fout.close();
return 0;
}
Comment