943,923 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1460
  • C++ RSS
May 5th, 2006
0

homework help please

Expand Post »
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, 8 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tydruk is offline Offline
9 posts
since Apr 2006
May 5th, 2006
0

Re: homework help please

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, 1 views)
File Type: xml EuroopaLiit.xml (3.0 KB, 1 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tydruk is offline Offline
9 posts
since Apr 2006
May 5th, 2006
0

Re: homework help please

Quote ...
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.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
May 5th, 2006
0

Re: homework help please

>> 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"
C++ Syntax (Toggle Plain Text)
  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. }
Reputation Points: 12
Solved Threads: 0
Light Poster
dude543 is offline Offline
26 posts
since Apr 2006
May 6th, 2006
0

Re: homework help please

inline int pmin(int h, int m){return (h*60 + m); }
is that the conversion i should use to convert hours to minutes?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tydruk is offline Offline
9 posts
since Apr 2006
May 6th, 2006
0

Re: homework help please

Quote 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"
C++ Syntax (Toggle Plain Text)
  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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tydruk is offline Offline
9 posts
since Apr 2006
May 6th, 2006
0

Re: homework help please

Yes , you might declare tocont as integer or even
as char.
Reputation Points: 12
Solved Threads: 0
Light Poster
dude543 is offline Offline
26 posts
since Apr 2006
May 6th, 2006
0

Re: homework help please

but where do i put it in my code - after, between or before the for statment that makes my program print?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tydruk is offline Offline
9 posts
since Apr 2006
May 6th, 2006
2

Re: homework help please

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.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,478 posts
since Jun 2005
May 7th, 2006
0

Re: homework help please

Quote 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tydruk is offline Offline
9 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: I Need Help!!
Next Thread in C++ Forum Timeline: Elementry C++.. little help for mods





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC