Results 1 to 3 of 3

Thread: Please Help, Quick!!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    14

    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

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    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

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width