Welcome! Log In Create A New Profile


Assignment 2 Question5

Posted by vionectro 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment 2 Question5
May 08, 2006 09:56PM
Hi, In assignment 2 Q5 they give a example of what the race record and race limit for a race can look like in seconds. The example quotes the numbers 101654 and 97200. If this is in seconds like stated that equates too 28:14:14 and 27:00:00. These examples seem to be outside the maximum range that we will ever have giving start and end hh:mm:ss. surely a record or limit should always be less than 24:00:00 as we do not specify start and end dates and we need too enforce times in the range of 00:00:00 and 23:59:59?
Re: Assignment 2 Question5
May 08, 2006 11:22PM
I just divided them by 10. I think they made a mistake but I did not see any corrections posted anywhere.

Re: Assignment 2 Question5
May 09, 2006 06:29AM
One more question regarding Question5.

In question 5 it is stated that "You may assume that the detail for a specific distance is separated by a blank from the detail for the following distance."

Would you agree that they are referring to something like the following:

10 101654 97200 21 101654 97200


10 101654 97200
21 101654 97200

Any ideas?
Anonymous User
Re: Assignment 2 Question5
May 09, 2006 02:19PM
Looking at the question 10 is the distance, 101654 maximum time in seconds and 97200 record time.
The way I understand it, this is not the start and end time for any runner, which has to be between 0 and 24 but could be any hours, instead the maximum time is a time at/or below which a runner is awarded a medal the record time is the time below which a runner will have set a new record time.
To me this can be any thing from 0 to any higher value.

On the last part of the question literally I think is 10 101654 97200 21 101654 97200 but I couldn't figure out how easy it would be to read the file so I took the last format which is
10 101654 97200
21 101654 97200
Re: Assignment 2 Question5
May 09, 2006 10:11PM
Yea I know its not the start and end time. I was just confused as to why would you have a minimum and a record time of 27h+ when you cannot ever have a runner time exceeding 24h.
Re: Assignment 2 Question5
May 10, 2006 07:25AM
Reading the values 10 101654 97200 21 101654 97200 ... from a file is not so hard.

It is basicaly one long input stream, hence you only need to do something like

ifstream fRecordsIn("infile.dat"winking smiley;
if ( fRecordsIn ) {

//read in up to first space
string temp;
fRecordsIn >> temp;

Just keep reading till eof if reached.

Hope this helps.
Re: Assignment 2 Question5
May 16, 2006 01:39PM
This question is actually very easy when you consider the use of multiple .cpp files and a header file with all prototypes. The secret is to break each function down and run it before you continue with the next function in a new .cpp file.
Re: Assignment 2 Question5
May 17, 2006 08:31PM
all fine and well, all prepared, yet I get the following error when compiling and running the actual program. any ideas?

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Studies\COS112V\Assignments\RoadRace.cpp" -o "C:\Studies\COS112V\Assignments\RoadRace.exe" -pg -g3 -L"C:\unisa\mingw\lib" -lgmon
C:\DOCUME~1\Stewart\LOCALS~1\Temp/ccEFcaaa.o(.text+0x50b): In function `main':

C:/Studies/COS112V/Assignments/RoadRace.cpp:60: undefined reference to `CalculateTime(std::string, std::string)'
C:\DOCUME~1\Stewart\LOCALS~1\Temp/ccEFcaaa.o(.text+0x786):C:/Studies/COS112V/Assignments/RoadRace.cpp:82: undefined reference to `UpdateMedals(std::string, std::string, std::string, int, double, bool)'
C:\DOCUME~1\Stewart\LOCALS~1\Temp/ccEFcaaa.o(.text+0x944):C:/Studies/COS112V/Assignments/RoadRace.cpp:84: undefined reference to `DisplayCount(int, int, int)'

Execution terminated
Re: Assignment 2 Question5
May 18, 2006 02:50AM
I had a similar issue.

Are all of your source files in the same project? If not, create a new project (File -> New -> Project) and add all the .cpp files and the .h file to your project by rightclicking on the project in the Project/Class browser and selecting "Add to Project". Then try again. Hope it helps.
Re: Assignment 2 Question5
May 18, 2006 08:19AM
Hi Stewart

Did u create a function CalculateTime in a new utility header file included in the structure:
#ifndef UTILITY_H
#define UTILITY_H
#here u declare your prototypes, like #include <iostream>

in the body of this struture u put your function whar ever it may be, remember it can not be a main function of the form int main() or Apimain().
int CalculateTime(string Start, string End) {

# endif

Then in your main .cpp you call utility.h as one of your header files through the statement,

#include "utility.h"
int main() {
call function...

Believe me it is as simple as that.

Re: Assignment 2 Question5
May 19, 2006 10:06AM
btw... did anyone have problems with the DisplayCount function? To me, it seemed really simple, and when I compiled my program it didn't complain about it.

*But it just didn't work.*

medals were updated correctly, etc, but there was just no display of the medal count appearing anywhere...
Re: Assignment 2 Question5
May 19, 2006 10:11AM
Hi Velvet

Here is a clue to solving your problem, you can call the same file through ifstream more than once in your program, you can call that same file in more than one .cpp file.

I hope this help.
Re: Assignment 2 Question5
May 19, 2006 11:08AM
DisplayCount gets passed 3 integers, ie: the counting of medals is already done. All the function needs to do is display the results it is passed. Why would I need ifstream?

After running my program, my medals.dat file was updated perfectly, but there was no display (I assumed by "display" they wanted it to go to monitor, not medals.dat) of the number of medals to be awarded. I experimented with cout and clog, to no avail. Am I just way off base or misunderstanding what the function needs to do?
Sorry, only registered users may post in this forum.

Click here to login