homework help please

Reply

Join Date: Apr 2006
Posts: 9
Reputation: tydruk is an unknown quantity at this point 
Solved Threads: 0
tydruk's Avatar
tydruk tydruk is offline Offline
Newbie Poster

homework help please

 
0
  #1
May 5th, 2006
homework(original function names in () )
i have done most of the job allready, but i can't seem to make it do exactelly what the program should.
My job is to make a program that asks numbers of busses(10,27,33,36) and the departure(valjus) times and save them into a txt document and then how many minutes has passed from the last departure(valjus) of the same buss. and also the program should check that the time(minutes and hours) are in the normal range from 0-24 h and 0-60 minutes and also it should check that the buss number entered is exacetelly the same number as given in the program.
It currently makes a txt document and saves the times, but i can't make the program calculate the time between(vahe) the departure(valjus) of the same number buss, it just doesn't do that. also, when i close the program window and start inserting the times and numbers again, it for some reason prints out the wrong time, but the new inserted buss number. my program doesn't brake, when '0' is entered as the buss number . i don't know what i'm doing wrong...
can you help me.
i have added my homework as well.
Attached Files
File Type: cpp harjutus15.cpp (1.9 KB, 7 views)
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 9
Reputation: tydruk is an unknown quantity at this point 
Solved Threads: 0
tydruk's Avatar
tydruk tydruk is offline Offline
Newbie Poster

Re: homework help please

 
0
  #2
May 5th, 2006
also i have a problem with my project, i need to get some info from a xml file and compare and print out few things.
everything is working fine, but the smallest countries area is 315,6 and every other area is a normal number like 12345 or something like that.
my problem is that that i can't get the 0,6 out from the xml, only the 315(i actually need 315+0,6)
what should i do?
should i just find the coma and then add the value after the coma or something else, but i have no idea how to put this into c++
i added my code and the xml file
Attached Files
File Type: cpp projekt22(1).cpp (4.6 KB, 0 views)
File Type: xml EuroopaLiit.xml (3.0 KB, 0 views)
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,885
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 299
Lerner Lerner is offline Offline
Posting Virtuoso

Re: homework help please

 
0
  #3
May 5th, 2006
i can't make the program calculate the time between(vahe) the departure(valjus) of the same number buss
No compiler available so I can't download cpp files. In general there are several ways to approach this:
1) you can transform hours and minutes to seconds, subtract the number of seconds from one time to the other and then convert back into hours and minutes.

2) Do routine math using base 60.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 26
Reputation: dude543 is an unknown quantity at this point 
Solved Threads: 0
dude543 dude543 is offline Offline
Light Poster

Re: homework help please

 
0
  #4
May 5th, 2006
>> my program doesn't brake, when '0' is entered as the buss number


Because you break from the for loop, but not from the
while loop.
I suggest a flag like "tocont"
  1.  
  2. tocont = 1;
  3. while ( tocont )
  4. {
  5. for(int i=0;i<4;i++)
  6. {
  7. if(nr==0)
  8. {
  9. tocont = 0;
  10. break;
  11. }
  12.  
  13.  
  14. }
  15. }
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 9
Reputation: tydruk is an unknown quantity at this point 
Solved Threads: 0
tydruk's Avatar
tydruk tydruk is offline Offline
Newbie Poster

Re: homework help please

 
0
  #5
May 6th, 2006
inline int pmin(int h, int m){return (h*60 + m); }
is that the conversion i should use to convert hours to minutes?
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 9
Reputation: tydruk is an unknown quantity at this point 
Solved Threads: 0
tydruk's Avatar
tydruk tydruk is offline Offline
Newbie Poster

Re: homework help please

 
0
  #6
May 6th, 2006
Originally Posted by dude543
>> my program doesn't brake, when '0' is entered as the buss number


Because you break from the for loop, but not from the
while loop.
I suggest a flag like "tocont"
  1.  
  2. tocont = 1;
  3. while ( tocont )
  4. {
  5. for(int i=0;i<4;i++)
  6. {
  7. if(nr==0)
  8. {
  9. tocont = 0;
  10. break;
  11. }
  12.  
  13.  
  14. }
  15. }
i really don't get it? do i have to declare docont as an intiger?
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 26
Reputation: dude543 is an unknown quantity at this point 
Solved Threads: 0
dude543 dude543 is offline Offline
Light Poster

Re: homework help please

 
0
  #7
May 6th, 2006
Yes , you might declare tocont as integer or even
as char.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 9
Reputation: tydruk is an unknown quantity at this point 
Solved Threads: 0
tydruk's Avatar
tydruk tydruk is offline Offline
Newbie Poster

Re: homework help please

 
0
  #8
May 6th, 2006
but where do i put it in my code - after, between or before the for statment that makes my program print?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,076
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 142
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: homework help please

 
2
  #9
May 6th, 2006
If you understand the language you're using, then you should have no problem running through the code by hand or in your head to see what happens, given some particular program. So do that.
All my posts may be redistributed under the GNU Free Documentation License.
9559449000 - lol you don't need modular exponentiation when using such small numbers
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 9
Reputation: tydruk is an unknown quantity at this point 
Solved Threads: 0
tydruk's Avatar
tydruk tydruk is offline Offline
Newbie Poster

Re: homework help please

 
0
  #10
May 7th, 2006
Originally Posted by Rashakil Fol
If you understand the language you're using, then you should have no problem running through the code by hand or in your head to see what happens, given some particular program. So do that.
but i don't understand the language, that is my big problem if did understand the code i wouldn't be her and asking but helping others...
please don't make me feel even more miserable then i allready am
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1404 | Replies: 9
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC