Thread: [HELP] Code to Convert Army Time to Normal Time?

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    10

    [HELP] Code to Convert Army Time to Normal Time?

    Like the program asks for the number of minutes and hours and it converts that to normal time.

    For example, if you put 23 hours then 14 minutes it then converts the time to 11:14.

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by Kipper DeVera View Post
    Like the program asks for the number of minutes and hours and it converts that to normal time.

    For example, if you put 23 hours then 14 minutes it then converts the time to 11:14.
    This is, once again, not a restaurant.

    You've got to cook your own meal. We can always help if something goes wrong, but you have to show the effort .

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    10
    Oh okay sorry, sorry. Imma upload my first try.

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by Kipper DeVera View Post
    Like the program asks for the number of minutes and hours and it converts that to normal time.

    For example, if you put 23 hours then 14 minutes it then converts the time to 11:14.
    Well, step 1 is to understand the problem. For instance, you do not. 11:14 is only part of the time denoted by 23:14. Are we in the am or pm? Honestly, is this even a real question, how hard is it? Did you notice any correlation betweem 23 and 11? How about 22 and 10?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #5
    Registered User
    Join Date
    Aug 2011
    Posts
    10
    Yep I do. But first I hafta figure out how to convert that to normal time, Dear god, I get it okay? I suck at programming. Okay now?

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main (){
    	int hour, minutes;
    
    	cout << "Please enter the number of hours: ";
    	cin >> hour;
    
    	cout << "Please enter the number of minutes: ";
    	cin >> minutes;
    	
    	if (hour == 13)
    		cout << "1" << endl;
    	if (hour == 14)
    		cout << "2" << endl;
    	if (hour == 15)
    		cout << "3" << endl;
    	if (hour == 16)
    		cout << "4" << endl;
    	if (hour == 17)
    		cout << "5" << endl;
    	if (hour == 18)
    		cout << "6" << endl;
    	if (hour == 19)
    		cout << "7" << endl;
    	if (hour == 20)
    		cout << "8" << endl;
    	if (hour == 21)
    		cout << "9" << endl;
    	if (hour == 22)
    		cout << "10" << endl;
    	if (hour == 23)
    		cout << "11" << endl;
    	if (hour == 24)
    		cout << "12" << endl;
    
    	cout << "The time is " << hour << " : " << minutes << endl;
    
    return 0;
    }

  6. #6
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    No, you don't seem to get it. Do you know how to add and subtract?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  7. #7
    Registered User
    Join Date
    Aug 2011
    Location
    Montreal, Quebec, Canada
    Posts
    73
    Hint. The answer is 12.

  8. #8
    Registered User
    Join Date
    Aug 2011
    Posts
    10
    Uhh herpderp. Yes, yes I do.

  9. #9
    Registered User
    Join Date
    Aug 2011
    Location
    Montreal, Quebec, Canada
    Posts
    73
    Then use that number. And substraction.

  10. #10
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by Kipper DeVera View Post
    Uhh herpderp. Yes, yes I do.
    Good response, especially considering it appears everyone here but you knows how to do this.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Convert time difference into seconds?
    By deadrabbit in forum C Programming
    Replies: 3
    Last Post: 08-13-2011, 03:35 PM
  2. Convert String to time
    By Alander in forum C Programming
    Replies: 3
    Last Post: 11-08-2007, 07:05 AM
  3. Convert Values Into Time And Kbps Or Mbps
    By amitmistry_petl in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2007, 06:48 AM
  4. Convert char* time to const tm*
    By stickman in forum C++ Programming
    Replies: 10
    Last Post: 11-14-2006, 09:24 PM
  5. Convert Time
    By Bones in forum C++ Programming
    Replies: 1
    Last Post: 09-05-2003, 03:25 PM