954,123 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

homework help please

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.

Attachments harjutus15.cpp (1.87KB)
tydruk
Newbie Poster
9 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

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

Attachments projekt22(1).cpp (4.58KB) EuroopaLiit.xml (3KB)
tydruk
Newbie Poster
9 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 
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.

Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
 

>> 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"

tocont = 1;
while ( tocont )
      {
      for(int i=0;i<4;i++)
          {
          if(nr==0)
               {
               tocont = 0;
               break;
               }
           
 
         }
     }
dude543
Light Poster
26 posts since Apr 2006
Reputation Points: 12
Solved Threads: 0
 

inline int pmin(int h, int m){return (h*60 + m); }
is that the conversion i should use to convert hours to minutes?

tydruk
Newbie Poster
9 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

>> 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"

tocont = 1;
while ( tocont )
      {
      for(int i=0;i<4;i++)
          {
          if(nr==0)
               {
               tocont = 0;
               break;
               }
 
 
         }
     }


i really don't get it? do i have to declare docont as an intiger?:confused:

tydruk
Newbie Poster
9 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

Yes , you might declare tocont as integer or even
as char.

dude543
Light Poster
26 posts since Apr 2006
Reputation Points: 12
Solved Threads: 0
 

but where do i put it in my code - after, between or before the for statment that makes my program print?

tydruk
Newbie Poster
9 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

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.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176
 
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 :sad: 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

tydruk
Newbie Poster
9 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You