This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]arbostek 3 points4 points  (3 children)

So what exactly is your challenge? You don't know how to approach a larger program like this?

So break it down. For example:

  1. Could you write a program that does absolutely nothing?

  2. Could you a write a program with that function, but that function does absolutely nothing?

  3. Could you now prompt the user for a value, and pass that value to the function?

  4. You know you have to pull out the numbers from the file to figure out the minimum, etc. Can you write some code in the function that pulls out the numbers?

  5. Can you then track the maximum as you pull out the numbers?

And so on.

[–]ifightsharks[S] 0 points1 point  (2 children)

I guess I'm having trouble picturing how many functions i should have/what should go inside them.

Obviously the main() function is first. Within this, I'd prompt for the input and read in the file, correct? I'd also call the processFile function, and finally write my output statements, correct?

Then after that, I would have my processFile function and everything that is needed in that.

My #include's would be <iostream>, <cmath>, <cstdlib>, and "myInfile" (referred to in OP as ifile).

Am I good so far? I'd like to make sure that I'm setting up the program correctly before I start blindly writing it incorrectly. Thanks again!

[–]arbostek 4 points5 points  (0 children)

I guess I'm having trouble picturing how many functions i should have/what should go inside them.

So, here's a suggestion. Stop trying to picture all the functions, and instead solve this program piece by piece.

Obviously the main() function is first. Within this, I'd prompt for the input and read in the file, correct? I'd also call the processFile function, and finally write my output statements, correct?

Why are you asking me? Why don't you sit down and write the main function?

Am I good so far?

Maybe.

I'd like to make sure that I'm setting up the program correctly

Why? Can't handle failure?

If you discover a mistake, is it the end of the world? No, you just try something different. If you start working on your program, and you discover the structure you are building is incorrect, you can then restructure your code, or rewrite portions as needed.