|
-
Sep 25th, 2001, 03:31 AM
#1
Thread Starter
New Member
Please Help, Quick!!!!
my friend has an assignement due tomorrow --- honest it's my friend not me ,
she's trying to write a program that converts sec to mins and secs
ex. 190 seconds is equal to 3mins and 10secs
this is her non working code:::: --- PLEASE HELP!!!!!!!!!!! reply with this code fixed PLEASE!!!!!!!!!!!!// minAndSec.cpp
// Demonstrates conversion of seconds to minutes and seconds.
#include <iostream>
using namespace std;
const int minute = 60;
int main ()
{
//Announce purpose of program:
cout <<"This program converts seconds to minutes and seconds."<<endl;
//User inputs seconds to be converted:
int seconds; // to be input from user
cout <<"enter seconds: ";
cin >> seconds;
//Check error state
if (!cin) {
cout <<"You must enter intergers only." << endl;
return 1;
} // if
//Convert seconds to minutes and seconds in integers:
int minutes = int seconds % 60
//Display the results:
cout << int seconds << " seconds is equivalent to"
<< int minutes
<< " minutes and "
<< % << " seconds." << endl;
return 0;
} // function main
-
Sep 25th, 2001, 04:18 AM
#2
Addicted Member
I've just made a few changes.
Code:
#include <iostream.h>
const int minute = 60;
int main ()
{
//Announce purpose of program:
cout <<"This program converts seconds to minutes and seconds."<<endl;
//User inputs seconds to be converted:
int seconds; // to be input from user
cout <<"enter seconds: ";
cin >> seconds;
//Check error state
if (!seconds)
{
cout <<"You must enter intergers only." << endl;
return 1;
} // if
//Convert seconds to minutes and seconds in integers:
int second = seconds % minute ;
int minutes = seconds/minute;
//Display the results:
cout << seconds << " seconds is equivalent to " << minutes << " minutes and " << second << " seconds." << endl;
return 0;
} // function mainin
} // function main
-
Sep 25th, 2001, 09:37 AM
#3
except at the end there's a typo:
} // function mainin
} // function main
there should be only one end bracket. Except for this it should work.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|