I NEED HELP IM SUPPOSE TO WRITE A PROGRAM..IM SUPOSE TO INPUT AN AMOUNT OF TIME IN SECONDS..THEN THE PROGRAM SHOULD OUTPUT IT IN WEEKS,DAYS,HOURS,MINUTES,AND SECONDS, USING THE LARGER UNITS AS MUCH AS POSSIBLE..FOR EXAMPLE PLEASE ENTER AN AMOUNT IN SECONDS: 1000...OUTPUT SHOULD BE O WEEKS,O DAYS , O HOURS,16 MINUTES AND 40 SECONDS...IM JUST STARTING TO LEARN SOO ITS WAY WRONG I NEED HELP WITH THE STRUCTURE THIS IS SUPPOSE TO BE A STARTER PROJECT NOT A COMPLICATED ONE BUT IM CONFUSED...I WOULD GREATLY APPRECIATE ANY HELP THANX :)
#include<iostream>
#include<string>
using namespace std;
// equivalencies provided
const int 1 minute is 60 seconds
const int 1 hour is 60 minutes
const int 1 day is 24 hours
const int 1 week is 7 days
nt main(void)
{
{cout << "Please enter an amount in seconds";
// Closes the program after letting user read output.
cout << endl << "Press ENTER to finish...";
cin.ignore(99,'\n');
return 0;
}
im really not sure where to begin here ... perhaps first you should catch up on your readings for the class
are these your declarations?
const int 1 minute is 60 seconds
const int 1 hour is 60 minutes
const int 1 day is 24 hours
const int 1 week is 7 days
If so there wrong you should check out how to do that as well they don't really need to be const but i suppose its not a bad idea to make them so
There not declared right eather simple declarion would be int i = 6; //end a declaration with a ; oh and you can put a comment out to the side to remind you what it is or even name the variable some thing like day for easer use
Before You Ask
Before asking a question a, do the following:
1.Try to find an answer by searching the archives of the forum you plan to post to.
2.Try to find an answer by searching the Web. 3.Try to find an answer by reading the manual.
4.Try to find an answer by reading a FAQ.
5.Try to find an answer by inspection or experimentation.
6.Try to find an answer by asking a skilled friend.
oh and your main should be declared some thing like this
1 2
int main(){
return 0;}
you should look in to cin to get data from the user too so you can input ....
1 2 3
int v;
cin >> v;
//this will get data form the user and store it in v so you can modify it
i would also look in to a while statement so the program can keep running so you can keep entering and formating data
oh thanx
i fixed my declarations im missing a lot after u input the seconds and where it ends.. perhaps if u saw what im suppose to do you could understand what im trying to do???..im not saying do my hw but ive been working on it reading it but honestly he didnt explain it good thats why
#include<iostream>
#include<string>
using namespace std;
// equivalencies provided
const int SECONDS_IN_MINUTE = 60;
const int MINUTES_IN_HOUR = 60;
const int HOURS_IN_DAY = 24;
const int DAYS_IN_WEEK = 7;
int main(void)
{
cout << "Please enter an amount in seconds: ";
cin >> Seconds;
// cin.ignore(99,'\n');
// Closes the program after letting user read output.
cout << endl << "Press ENTER to continue...";
cin.ignore(99,'\n');
return 0;
}
well think of it this way your getting the values in the form of seconds right?
just use simple multiplication and devision to get the value in days and hours and what not .. once you get the simple conversion you can out put it to the user
1 2 3 4 5 6
//example
int i = 0;
int min = 60;
cin >> i;
i = i/min; //this makes i in to hours
look up while loops in your book so your program dose not end early
and you can keep putting in data
also you might wanna look in to if...else statments
so the program doesnt end he told us to put these:
//cin.ignore(99,'\n');
heres the example of what i should do maybe its easier to understand
ftp://www.sacbusiness.org/downloads/cs/hesterj/cs121/
click ..Gold02.exe u mite need to refresh it since its ftp