Numbers past the decimal point troubleshooting

Hi folks,

I am very new to programming, like many people who are posting on this beginners forum. The issue I am having is with showing numbers past the decimal point. Please refer to coding below. The problem I am having specifically is that all my values are being outputted with the additional numbers past the decimal point. The only values I want to have shown that way are my "numMinutes", "numHours", and "numDays". Unfortunately, my outputs end up as such:

Enter a number of seconds, please:
89999
There are 1499.98328 minutes in 89999.00000 seconds.
There are 24.99972 hours in 89999.00000 seconds.
There are 1.04166 days in 89999.00000 seconds.
Press any key to continue . . .

Please help me identify what idiot mistake I am making. Thank you very much for any input you may have on this subject.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  #include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	
	float numSeconds = 0;
	double numMinutes = 0;
	double numHours = 0;
	double numDays = 0;

	std::cout << std::setprecision(5) << std::fixed;
		
	cout << "Enter a number of seconds, please:\n";
	cin >> numSeconds;

	numMinutes = numSeconds / 60; // Calculation Minutes //
	numHours = numSeconds / 3600; // Calculation Hours //
	numDays = numSeconds / 86400; // Calculation Days //


	if (numSeconds >= 60);
	cout << " There are " << numMinutes << " minutes in " << numSeconds << " seconds." << endl;
	if (numSeconds >= 3600)
	cout << " There are " << numHours << " hours in " << numSeconds << " seconds.\n";
	if (numSeconds >= 86400);
	cout << " There are " << numDays << " days in " << numSeconds << " seconds.\n";



	system("pause");

	return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <iomanip>

int main()
{
	const double SECS_PER_MINUTE = 60 ;
	const double SECS_PER_HOUR = SECS_PER_MINUTE * 60 ;
	const double SECS_PER_DAY = SECS_PER_HOUR * 24 ;

	unsigned long long numSeconds = 0;
	std::cout << "Enter a number of seconds, please:\n";
	std::cin >> numSeconds;

	const double numMinutes = numSeconds / SECS_PER_MINUTE ; // Calculation Minutes //
	const double numHours = numSeconds / SECS_PER_HOUR; // Calculation Hours //
	const double numDays = numSeconds / SECS_PER_DAY ; // Calculation Days //

	std::cout << std::setprecision(5) << std::fixed;

	if (numSeconds >= SECS_PER_MINUTE )
	    std::cout << "\n There are " << numMinutes << " minutes in " << numSeconds << " seconds.\n" ;

	if (numSeconds >= SECS_PER_HOUR )
	    std::cout << " There are " << numHours << " hours in " << numSeconds << " seconds.\n" ;

	if (numSeconds >= SECS_PER_DAY )
	    std::cout << " There are " << numDays << " days in " << numSeconds << " seconds.\n" ;
}
std::cout << std::setprecision(0) << std::fixed;
Topic archived. No new replies allowed.