Question: Write a program that asks the user to enter a number of seconds, and w
ID: 672494 • Letter: Q
Question
Question: Write a program that asks the user to enter a number of seconds, and works as follows:
There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds.
There are 3600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3600, the program should display the number of hours in that many seconds.
There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.
I need help programming this on visual basic, and he is only giving us 1 hour to do it. can someone please help me ?
Explanation / Answer
// ConsoleApplication8.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include <cstdlib>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
long int seconds,s,hours;
int days, minutes;
cout << "Enter the number of seconds: ";
cin >> s;
days = s / 60 / 60 / 24;
hours = (s / 60 / 60) % 24;
minutes = (s / 60) % 60;
seconds = s % 60;
cout << days << " days, "<<hours<<" hours," << minutes << " minutes, " << seconds << " seconds"<<endl;
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.