I think i have the basics down for this program but I still am not sure what to do after. I have attached my assignment and my code so far.
I think i have the basics down for this program but I still am not sure what to do after. I have attached my assignment and my code so far.
That's a unique assignment. Long to read, but actually really simple.
What are you having problems with? Posting a requirements spec. and some source code doesn't let anyone help you.
Well the problem i am having is being able to make it so that it outputs it in that way. I know how to get the first output for time 0, but I have no idea how to get the other times to work. I tried using while and nested for loops but I just don't get how to do it.
please help me :'(. I been stuck on this for 4 hours.
Last edited by David Park; 07-28-2014 at 07:05 PM.
Looked at the code more, found a few things :
1) Arrays in C are 0-based. In your code you are indexing from 1 to SIZE, when you need to index from 0 to SIZE-1.
2) You may need to rethink your control loop for outputting the configurations.
I suggest having an array of 15 boolean flags (T = alarm sounding, F = not sounding). The values of 45 and 120 are arbitrary.
at time 0, the configuration is equal to the one entered by the user.
then make a loop that continually updates your array until every value is T.
Or you could use this:
That way, you can input as integers but use more meaningful names inside program.Code:enum AlarmStatus { ON = 45, OFF = 120 }; enum AlarmStatus STATIONS[NUM_STATIONS]; scanf("%d", &STATIONS[i]); if (STATIONS[i] == ON) // ...
Last edited by MacNilly; 07-28-2014 at 07:19 PM.
Could you give an example as to how to do that in code format? I am in an introductory CS class, so I am not the most experienced programmer.
I can't use enum in my assignment because the class restricts to the materials we learned so far. Could you show the boolean method in code? I hope I am not asking for too much, it's greatly appreciated.
I can't and wouldn't post a complete source code.
Homework policy.
Since you can't use enums, you might as well just use a define like so
Code:#define ALARM_ON 120 #define ALARM_OFF 45
Ok, I'll just post an outline of a simple algorithm.
I think that is about as far as I can go!Code:int done = 0; while (!done) { // display current station conf. displayStations(); // update station conf. updateStations(); if (all stations alarms sounding) done = 1; }
Thank you! It helps!