#include <iostream>
int main(int argc, const char * argv[]) {
float m = 17*50/60*5; // m = le coût par jour ( 17$ de l'heure * 50 employés / 60 min * 5 min )
std::cout << "Coût par jour = " << m <<std::endl;
std::cout << "Coût par Semaine = " << m * 5 <<std::endl; //coût par jour * 5 jours semaine
std::cout << "Coût par mois = " << m * 5 * 52 /12 <<std::endl; // coût par jour * 5 jour semaine (coût par semaine) * 53 semaine (coût par année) / 12 mois (coût par mois)
std::cout << "Coût par année = " << m * 5 * 52 <<std::endl; // coût par jour * 5 jour semaine (coût par semaine) * 52 semaine
return 0; //fin
}
So I am really new to coding (Also sorry the whole thing is in French). This is a problem for a class where I had to calculate the money loss by people smoking (50 people, paid 17$/h, 5 min of smoking each day) per day, per week, per month and per year. I'm using Xcode if it matter and here is the result I got:
Coût par jour = 70
Coût par Semaine = 350
Coût par mois = 1516.67
Coût par année = 18200
Program ended with exit code: 0
If I do the math by hand, it's not at all right and I realized it's because the code rounds m (at first I only did 17/60*5 so I would have per person but it gave me 0 everywhere.) Since I am using float, I thought It shouldn't round it? I'm confuse if I did something wrong. I'm not trying to have someone do my homework for me, but it's just that part that I don't know how to fix. Thanks!