Here i want to calculate the number of sweets that i have been sold in Day 2.
int main()
{
float rate;
int left, total, sell ;
cout << "rate" ; // the rate that sweets have been sold per day
cin >> rate;
cout << "sell"; // number of sweets that have been sold in day1.
cin >> sell;
cout << "total"; // total number that the shops originally have
cin >> total;
left = total - sell;
sell = sell*(1+rate*(left/total));
cout << sell;
return 0;
}
And i want to calculate the numbers of sweets that have been sold in day2. Assume the input are rate = 0.5, sell=100, total = 10000. The output should be 14950. [ 10000 * (1+0.5*((10000-100)/10000)) ] But why I still get 10000 after running the program.
Updated:
However, I have one more question. If i want to output a rounded up sell
value. How could I do it? because i am not allowed to change the datatype of the variables, which means it should be still int sell;
at the initialization part. I have tried cout << round((double) sell);
But it still does not work.