Thread: stuck on this.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    8

    stuck on this.

    Here's what i'm supposed to do.

    Write a program that asks the user to enter a number of seconds.

    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 3,600 seconds in an hour. If the number of seconds entered by the user
    is greater than or equal to 3,600, the program should display the number of hours
    in that many seconds.

    There are 86,400 seconds in a day. If the number of seconds entered by the user is
    greater than or equal to 86,400, the program should display the number of days in that many seconds.

    There are 1666.667 minutes in 100000.000 seconds.
    There are 27.778 hours in 100000.000 seconds.
    There are 1.157 days in 100000.000 seconds.

    Code:
    #include <iostream>
    #include <iomanip>
    using namespace std;
    int main()
    {    
    double seconds;    
    double minutes = 60.0;    
    double hours = 3600;   
    double days = 86400;    
    
    cout << "Enter a number of seconds: " << endl;    
    cin >> seconds;    
    cout << fixed << showpoint << setprecision(1);   
    
     if (minutes >=60)    
    { cout << "There are minutes in seconds." << setw(1) << minutes << endl;}    
    cout << fixed << showpoint << setprecision(1);    
    
    if (hours >=3600)    { cout << "There are hours in seconds." << setw(1) << hours << endl;}  
    cout << fixed << showpoint << setprecision(1)
     
     
    if (days >=86400)   
    { cout << "There are days in seconds." << setw(1) << days << endl;} 
    return 0; }
    can i do this problem with a if statement because i can't use loops since i didnt learn it yet.

    i don't know if i'm doing it right so please help.
    Last edited by typeqwerty; 09-25-2012 at 06:52 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just stuck indeed
    By TAboy24 in forum C++ Programming
    Replies: 3
    Last Post: 11-19-2007, 04:32 PM
  2. Stuck - Need a little help
    By nevek in forum C Programming
    Replies: 9
    Last Post: 06-11-2007, 03:57 PM
  3. A little stuck.. is this possible?
    By Ganoosh in forum C++ Programming
    Replies: 6
    Last Post: 07-20-2005, 03:06 PM
  4. Stuck with '\b'
    By pratip in forum C++ Programming
    Replies: 5
    Last Post: 10-28-2003, 07:49 AM
  5. Stuck again!
    By shewolf in forum C++ Programming
    Replies: 17
    Last Post: 10-23-2003, 12:27 PM