• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

COMP115 ass3 (1 Viewer)

pb

Inside The Hollow
Joined
Jan 20, 2004
Messages
775
Location
Westie!
Gender
Female
HSC
2003
ahhh no don't like new lecturer... he points to u and embarrasses u when u talk. He did that to my friend who wasn't even talking!

i prefer french dude. His accent was hard to understand, but he was still better
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
Originally posted by ND
Hmmm not sure how i'm gonna do the bonus...
you could have a student class that has all the info (name, id, avg mark, grade etc). you could keep them in a linked list ordered by avg mark (ie highest mark at the start of the list, lowest at the end). finding the highest would be O(1), finding the lowest would be O(N) but easy (just traverse to the end), printing out the summary would be easy, just print out the excellent heading, then traverse the list printing till you get "good" mark, print the good heading, traverse and print and so on.

theres swisher ways of doing it but thats pretty straight forward
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
Originally posted by Rahul
i havent used them yet...comp is studpid...you dont need to "study" till before the finals....just need to do assignments.
i prefer doin assignments.
not to sound like your parents but: thats true but in the harder subjects make sure you understand all the stuff covered in the week, otherwise its too much to study for. like comp225, none of the concepts are particularly hard, theres just a lot of them you need to remember.
 
Last edited:

Rahul

Dead Member
Joined
Dec 14, 2002
Messages
3,647
Location
shadowy shadows
yeh....i understand, i have done c++ before, thats why i can 'bludge' a lot more. not the case with my other subjects though...lol, they are all new.

doe, seems like you have some comp units? or know stuff about them. what would be the next comp unit after COMP115, thats isnt relatively hard and does c++?
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
im doing a computing degree, so have done most of the comp units. i think after comp115 you do comp125, which is in c++ yes. it used to be in this unimpressive language called eiffel, but they changed it to be c++ cause thats what you'll use in comp225. another popular language is python you use for natural language stuff (comp249, comp348 and i think comp248 and comp349) and the university has bought in a few new subjects using java (comp229 and some other ones i think)

comp125 being hard is relative, i think its the first "real" programming subject, so they cover some material which may be unfamiliar to you like linked lists and objects. by real i mean its done predominatly by computing students, whereas 115 and 114 are done by a whole slew of people who study some other field and their degree just has a computing component so they have some basic skills/understanding. in the grand scheme of things the stuff in 115 and 125 are fairly easy but very important, so take the time to understand them and c++ well, as you'll be using c++ in other more advanced comp subjects at uni, and the concepts for the rest of your career as a programmer. trust me when i say understanding this stuff now will save you a world of pain later on. in second and third year the assignments get progressively more complex, and not understanding the language makes it that much harder to do them.

programming is a practical skill, and in my opinion it should be taught as a trade or craft, like a plumber or carpenter, not in a university. the more you do it the better you get. passing exams which are usually worth 70 - 80% of a subject is a case of being able to remember a lot of stuff for three hours. in the end, passing exams is how people judge if you "did well" at university, but try and pick up some skills while you're here.

oh if you need help with a comp assignment ask here or perhaps in #macuni on austnet (later at night more people are around) as its got a lot of comp students. im trying to cut down on my internet usage so dont check here much, so irc might be the best bet
 
Last edited:

Rahul

Dead Member
Joined
Dec 14, 2002
Messages
3,647
Location
shadowy shadows
thanks, i'm not doing a comp degree, so i dont know if i'll do any further comp subjects as electives. just want to get a general idea.

i agree with your comment about programming as a practical skill. i learnt c++ by watching one of my friends coding, and then coding myself. there is only so much you can be taught by someone else, you have to do it on your own.
 

Wacky

Who me?
Joined
Nov 30, 2002
Messages
41
Gender
Male
HSC
2003
Back on topic, I'm always a bit confused by these comp assignments - they always have these strange typos which mysteriously disappear from the site when I ask people about it (I have a printout to prove it! really!)

Anyway

Assignment 3 - the question thing:

scroll down a lot "You are required to give the definitions of declarared user-defined functions"

Don't you need that for the program to compile in the first place?

Source files:

regular:

This is a section of the original source:
.
.
.
// delcare other variables

inFile.open("students.txt"); // don't change any in this line
outFile.open("report_regular.txt"); // don't change any in this line
// don't use any absolute path for an input/output file


// input data and process them Lets call this point 1


outFile<<endl<<"+++++Section 1 Student List+++++"<<endl<<endl; // don't change any in this line

// output the data of section 1 to outFile Point 2


.
.
.

I notice that declare is spelt wrong.

Anyway:

Does the comment at point 1 mean that we have to process it between point 1 and point 2 (i.e. first do all the processing, then after point 2 do only outputting and no processing), or point 1 and the end (i.e you can do processing everywhere)?


bonus:

this got answered in the FAQ. So who's using those rather random functions?

anyone going to delete them?
 
Last edited:

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
Originally posted by Wacky
scroll down a lot "You are required to give the definitions of declarared user-defined functions"

Don't you need that for the program to compile in the first place?
it depends on the compiler. some will just warn you about it, some will error out, in some languages its standardized that you must have it, im not sure about c++ and cant be arsed checking. the reaon its there is so the compiler can check the arguments for each function call are of the correct type. c has all functions implictly declared to return an int, implicit function declarations are the tool of the devil though. its considered sloppy not to put prototypes in. an easy way to avoid having to type out the prototype is to declare the function before it is used in the source file. say i have supplementary functions foo() and bar() used by main(), if my source file is laid out like this

int
foo(void)
{
...
}

int
bar(void)
{
...
}

int
main(void)
{
...
foo();
...
bar();
...
}

everything will be ok. if main() appears before foo() and bar() the compiler will generate a warning and maybe even error out. to stop this youd just put in a prototype eg

int foo(void);
int bar(void);

int
main(void)
{
...
}

int
foo(void)
{
...
}

and so on.

Originally posted by Wacky

Does the comment at point 1 mean that we have to process it between point 1 and point 2 (i.e. first do all the processing, then after point 2 do only outputting and no processing), or point 1 and the end (i.e you can do processing everywhere)?
i think its just a guide to how you might want to do it, im 99% sure you wouldnt be penalised for processing and outputting as you read them in, but mail your lecturer to be sure.
 

pb

Inside The Hollow
Joined
Jan 20, 2004
Messages
775
Location
Westie!
Gender
Female
HSC
2003
i cant either :(
i tried to do the leap year thing.. and i have no idea wat that has to do with the question
but my leap year function thing is probably wrong
 

Orange Juice

so worthless i am
Joined
Nov 23, 2002
Messages
3,886
Location
Room 112
Gender
Male
HSC
2007
Originally posted by jezzmo
*phew*. it's not just me.
i think this weeks exercise is one of those things im just going to put a "I tried but failed" comment in my file. Not that I really have tried...but the failing part is true.
so true... just submit the template... as long as you submit something its all good
 

Wacky

Who me?
Joined
Nov 30, 2002
Messages
41
Gender
Male
HSC
2003
... Took me ages to do that weeky exercise.

Hint: you will need a funtion that gets you the lenght of a particular month of a particular year

Hint2: Then you need to do some calculations. Maybe like which date is first

Hint3: Then start with the first, calculate number of days to the end of the month, add a whole lot of month lengths, then number of days from the beginning of the month to the last date.

But don't just submit the template - you can probably get more imaginary marks by having if-then statements for the examples :D :D

oh, and what do you think of this:

#include < iostream.h > //spaced out so they show up
#include < stdlib.h >
#include < string >
#include < iomanip >

int main()
{
string str;
str = "hello";
cout.setf(ios::left);
cout << setw(6) << str << setw(6) << str << endl;
cout << setw(6) << "hello" << setw(6) << "hello" << endl;


system("PAUSE");
return 0;
}

Prints out:

hellohello
hello hello
Press any key to continue...

Why doesn't setw seem to work on strings?
Even if you change it to ios::right or delete the line altogether?
 
Last edited:

...

^___^
Joined
May 21, 2003
Messages
7,723
Location
somewhere inside E6A
Gender
Male
HSC
1998
hint 2 is kinda irrelevant cos they expect a negative answer if you are counting backwards

i'm trying to do hint 3
thats the problem, adding the months
 

pb

Inside The Hollow
Joined
Jan 20, 2004
Messages
775
Location
Westie!
Gender
Female
HSC
2003
I've done half of Section 1 of the assignment. I wanted to do it early to get it out of the way, but im lost already lol.
 

sukiyaki

emptiness
Joined
Nov 9, 2002
Messages
1,505
Location
westie
Gender
Female
HSC
2003
Originally posted by pb
I've done half of Section 1 of the assignment. I wanted to do it early to get it out of the way, but im lost already lol.
you can help me!!
 

MicK_eT

Terry mate!
Joined
Jul 2, 2003
Messages
287
Location
south west sydney
:( i feel like breaking down and crying.. comp is sooo evil.. i cant do any of the evil weekly exercises and i cant do the assignment 3.. grr... evil exams at teh end of semester.. *sighs*

maths is evil now too... *sigh*... i dunno what the hell they are doin now... hahah.. hmmmz...
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top