#include <iostream>
#include <limits>
int main ()
{
int totalminutes; //User input of minutes.
int hours; //Using totalminutes/60.
float minutes; //Using (totalminutes%60) * 60.
int hoursmoney; //Using hours * $5.
float minutesmoney; //Using minutes * (5/60).
float earnings; //Using hoursmoney + minutesmoney.
//Starting program, asking for user input. Storing to totalminutes
std::cout << "OT Calculator. Version 0.01" << std::endl;
std::cout << "Accuracy of calculation is ESTIMATED." << std::endl;
std::cout << "Please double check with your own calculator." << std::endl;
std::cout << std::endl;
std::cout << "Please enter your total minutes. " << std::endl;
std::cin >> totalminutes;
//Calculating totalminutes into hours and minutes. Storing to variables.
hours = totalminutes/60;
minutes = totalminutes%60;
//Calculating hoursmoney, minutesmoney and earnings. Storing to variables.
hoursmoney = hours * 5;
minutesmoney = minutes * 0.08333;
earnings = hoursmoney + minutesmoney;
//Showing user information gathered.
std::cout << std::endl;
std::cout << "You have entered " << totalminutes << " minutes." << std::endl;
std::cout << "Based on the calculation of $5 an hour, " << std::endl;
std::cout << hours << " hours = $" << hoursmoney << std::endl;
std::cout << minutes << " minutes = $" << minutesmoney << std::endl;
std::cout << std::endl;
std::cout << "For " << totalminutes << " minutes, you earned $" << earnings << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;
//Exiting program.
std::cout << "Press ENTER to exit...";
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
std::cin.ignore();
return 0;
}
Please look at line 8.
float minutes; //Using (totalminutes%60) * 60.
and also look at line 25.
minutes = totalminutes%60;
Problem is here..by right at line 25, ii should have to do a minutes = (totalminutes%60)*60;
so by taking the remainder to * 60, i will be converting them to minutes..
but if i put the *60 inside, it will never be correct...
the codes itself seems to auto * 60 for line 25..
The logic as it is is correct. If x is a time span in minutes and you take the remainder of dividing x by 60, you'll get the sexagesimal digit for the minutes (i.e. how many more minutes that an integer hour the time span represents). If you multiply that by 60, you'll get how many more seconds than an hour the time span represents.