IT/Software career thread: Invert binary trees for dollars.

Tenks

Bronze Knight of the Realm
14,163
607
I haven't posted the final yet, I will look at your code and understand it and then put it in for this assignment though. I don't think it was supposed to be difficult in any way but just introduce functions. The way I understand it is so that you can come back to calculations whenever you want instead of putting them in multiple times right?
Methods have a few uses. The biggest use is code reusability. Like lets say your program does something complex. Lets pretend like it needs to calculate the area of a rectangle in multiple sectors of the code. So instead of constantly re-doing the implementation of how to calculate the area of a rectangle everywhere it is used you simply make it a method call. This is also good in case the rules for how you calculate the area of a rectangle changes you change it in one spot and everywhere that uses it gets the updated requirements.
 

a_skeleton_03

<Banned>
29,948
29,763
Here is the final.

final_sl said:
Final Project

Your final project will be to analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as at least one function call and the use of at least one array. The specific problem you need to solve for the final project is:

Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who lives in Texas.

There are 6 components of your submission including:

Program Description- A detailed, clear description of the program you are building.
Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input? Also, include your variable names and definitions. Be sure to describe the necessary formulas and sample calculations that might be needed. Talk about the functions you plan to use and how you will use arrays. Be sure to talk about the types of programming statements that will be used on why.
Test plan - Prepare at least 3 sets of input data (Test data) along with their expected output for testing your program. Your test data can be presented in the form of a table as follows (note: feel free to adapt to your design)
Pseudocode- Provide pseudocode of your overall design that fulfills the requirements of the project
Source Code
Demonstrated output (Screen Shots)
All of these components should be placed in word document for submission.

Additional details about the program you need to write:

Family sizes vary, however you should design to be able to enter at least 50 Family members.
Your test cases should have at least 5 family members.
Be sure to separate some functionality into functions or submodules. Having all functionality in the main module is not a good design.
Your design should consider how to indicate the family member entry is complete.
Carefully consider the best data type for each of your variables. (e.g. when to use Float versus Integers versus Strings)
Example application test data:

Test Case #InputExpected Output

1Fred, Age: 82, State: MD
Mary, Age:75, State: OH
Joe, Age: 45, State: TX
Julie, Age: 47, State: TX
Beth, Age: 9, State: TXAverage Age: 51.6
Members who live in TX:
Joe
Julie
Beth

2Your input dataYour expected output

3Your input dataYour expected output
 

a_skeleton_03

<Banned>
29,948
29,763
I will take a look at both and will of course post my revisions and such in here.

I would say someday I will be able to whip up code like that in less than an hour but then I remembered I have no desire to code ever again this is just a stupid prereq class. This is why I don't have a degree yet, I hate this bullshit contrived dependency system that has no basis in reality. Classes you "must" take.
 

Tenks

Bronze Knight of the Realm
14,163
607
I will say I think my above code will have an off-by-one error since I increment x inside the loop after the prompts. But I didn't want to do something like

Because I wasn't sure if you were aware of that syntax
 

a_skeleton_03

<Banned>
29,948
29,763
Probably has not learned about memory management and would advise against using 'new' in this case
I will look into that and at least make sure I understand why it is being used. No we haven't learned it but that doesn't mean we can't use it.

The teacher just cares if we used at least the things taught and if we do more advanced stuff he doesn't care. We just can't do it an entirely different way then the lesson plan has taught us.
 

Noodleface

A Mod Real Quick
38,245
15,030
I don't think you need to use new keyword is all. It adds certain complications if you haven't learned it. Tenks is trying to be a fancy boy.
 

Tenks

Bronze Knight of the Realm
14,163
607
I'm writing pseudo Java where everything outside of statics are constructed with new
 

Noodleface

A Mod Real Quick
38,245
15,030
I figured since I didn't see any semi-colons, and the prompt functions weren't declared, also no function prototypes ; ;
 

Tenks

Bronze Knight of the Realm
14,163
607
It wasn't really a language just the outline. The prompts are there because I couldn't be arsed to look up how to get console input from java and scanf can eat my butt.
 

Noodleface

A Mod Real Quick
38,245
15,030
Silly question that I can't remember

Is code inside #ifdef blocks compiled at all if the condition is false?

For instance:
Assume FLAG1 is FALSE and FLAG2 is TRUE. I know the second code block is obviously compiled, but is the first code block completely left out with no traces in the built executable/binary?
 

Tuco

I got Tuco'd!
<Gold Donor>
46,830
78,468
You guys showing off by providing full implementations (even pseudocode) of stuff a_skeleton_03 needs aren't helping him. At least let him struggle a bit to learn the concepts before telling him things like, "you need to put your functions above the main function, because the main function won't know wtf calculateArea is if it's below." or "you should probably use floating point numbers instead of integers in your system in case the professor tries to find the area of a rectangle of size 5.4 and 10.9".

But seriously, a_skeleton_03 if you're taking one programming class, why is it C++ and not say, bash?
 

a_skeleton_03

<Banned>
29,948
29,763
You guys showing off by providing full implementations (even pseudocode) of stuff a_skeleton_03 needs aren't helping him. At least let him struggle a bit to learn the concepts before telling him things like, "you need to put your functions above the main function, because the main function won't know wtf calculateArea is if it's below." or "you should probably use floating point numbers instead of integers in your system in case the professor tries to find the area of a rectangle of size 5.4 and 10.9".

But seriously, a_skeleton_03 if you're taking one programming class, why is it C++ and not say, bash?
I would learn if I was going to ever code again.

It is C++ because that is what they chose to be a prereq for the rest of my degree where I don't have a single other coding class. Not one.

CMIS 102 7984 Introduction to Problem Solving and Algorithm Design is the class name and it isn't really about coding per se but it kind of is and you are allowed to use C or C++ even if you know some other languages.

The professor isn't doing any gotchas with the code and doesn't care that you don't have error routes out or anything else. You don't even need to have the code compile correctly just "solve the problem" with the concepts given to you and that is 80% of the grade. I want to actually make the code work and I try to understand it well enough even if I never code again in my life that is why you see me dumping code in every so often while I chug away at it as a running though process.
 

Noodleface

A Mod Real Quick
38,245
15,030
It varies by compiler, but in general no it's not compiled but is tokenized(important since it'll cause compilation failure if there's invalid code in the block, even if the compiler discards it after).
You sure on the last part? I can put a false ifdef with "hisdhjkhgkjdshgksd" in it and it compiles. Perhaps that varies compiler to compiler.

The main reason I ask was from a security standpoint. I'm being forced to add some shitty code that I don't want anyone to ever be able to even accidentally or purposely hack and call unless the defines are set.


@a_skeleton_03, you have incorrectly declared area and perimeter.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,830
78,468
c/c++ seems like a weird choice for a algorithms class. What degree you getting bro?
 

Cad

scientia potentia est
<Bronze Donator>
25,342
48,526
c/c++ seems like a weird choice for a algorithms class. What degree you getting bro?
My intro to programming course in college was in pascal. The second one was in C. Of course this was in the mid 90's...