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

Deathwing

<Bronze Donator>
16,717
7,731
How do I take that count variable and use it to define how large my array would be? name[count] or something to that concept
Arrays are defined at compile time and live in the stack(when in scope), redefining their size at run time IS possible but dangerous and generally not recommended. This is exactly what things like vectors are for. Generally, if you have to use an array for that purpose, you make it as big as you think you're going to need it.
 

moontayle

Golden Squire
4,302
165
I was also wondering about that. In Java when you declare a primitive array (int[], String[], etc) you typically have to provide its size as well. It's not dynamic at all and primarily used when you know exactly what's going into it beforehand. When we're unsure we use ArrayList<T> and as we need items added or removed we use the provided methods.
 

Cad

scientia potentia est
<Bronze Donator>
25,338
48,507
Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed. Design your program to calculate the Grade Point Average (GPA) for each student based on each of their final grades. The program should output the Student name along with the GPA.
You don't need arrays and you don't need vectors. This is pseudocode, don't call me on syntax errors.
 

Tenks

Bronze Knight of the Realm
14,163
607
Yeah Cad's pseudo is what came to mind reading the problem but it may also need some requirement definition. Like at the end it wants you to ask if that is all. So do you need a condition at the end of the first for loop to ask if that is all and increase numOfStu? Do you need a prompt at the end of the second loop doing the same for numOfGrades? What does it mean store the name? Is it like Cad where he just remembers the name only for that loop execution? Do you need to know them all at the end?
 

Tenks

Bronze Knight of the Realm
14,163
607
Ah you're right. I read his list as the assignment instead of his interpretation of the requirements. I think Cad's idea is proper.
 

Cad

scientia potentia est
<Bronze Donator>
25,338
48,507
The way I read the assignment you don't even have to store the strings up in a buffer and print them at the end (although that would be neater) it just wants you to output them. So, just output them as soon as they are done inputting the grades.

This is a test to determine if you can write 2 for loops.
 

Deathwing

<Bronze Donator>
16,717
7,731
Storing information seems to be a common assumption when tackling a programming problem. IDK if it's because it makes the program flow easier, but I didn't catch that until Cad pointed it out.
 

a_skeleton_03

<Banned>
29,948
29,763
The way I read the assignment you don't even have to store the strings up in a buffer and print them at the end (although that would be neater) it just wants you to output them. So, just output them as soon as they are done inputting the grades.

This is a test to determine if you can write 2 for loops.
Yeah I think that is all he wants, nested loops, but I thought storing it would be easier.

This week is labeled "Repetition with Nested selection statement".

This is what I came up with a few minutes ago.

It's rough and sort of pseudocode but it might work.

I will take a look at what you posted and see what I can do with that.
 

Cad

scientia potentia est
<Bronze Donator>
25,338
48,507
Yours wont work because you don't know how many courses each student took. Some might have taken 1 some might have taken 10.
 

Cad

scientia potentia est
<Bronze Donator>
25,338
48,507
I thought I put in a statement asking how many they took, I will have to add that.
Predefining your array to have a maximum will get you docked points.

0,1, infinity rule says you never code things that can only take 10, 20, or 100, or 100,000 items. Either it takes 0 items, it's a singleton, or it can take infinity. My way takes infinity.
 

a_skeleton_03

<Banned>
29,948
29,763
Yeah this teacher is not docking for me defining arrays to be finite when he hasn't taught shit for shit and he definitely hasn't given us the link to the public tutorial website on arrays yet.

I am still reading yours and trying to wrap my head around it though to see if I get it right.
 

Noodleface

A Mod Real Quick
38,244
15,025
My bad for bringing up arrays. I thought he wanted you to collect all input then print all input. He really wants you to collect one, print, coll3ct, print, etc.
 

a_skeleton_03

<Banned>
29,948
29,763
My bad for bringing up arrays. I thought he wanted you to collect all input then print all input. He really wants you to collect one, print, coll3ct, print, etc.
Arrays to me seems easier now that I have done the research. I look at Cad's code and right now I am just blanking out on it, I am slowly figuring it out though.

Did I mention that I absolutely despise coding and that this is the ONLY coding class in my entire degree but it's a prerequisite for half of them.

The class name is - Introduction to Problem Solving and Algorithm Design and I thought it was just conceptual pseudocode only style. Ugh I hate coding.
 

Tenks

Bronze Knight of the Realm
14,163
607
What specifically is making Cad's code hard to understand? Like he said this is just a simple exercise in nested loops.
 

Deathwing

<Bronze Donator>
16,717
7,731
C isn't a great language to teach generic programming concepts. Intro to programming should really start out with Python, Ruby, or something similar. It's too easy to get tripped up on syntax or language-specific quirks in C.
 

a_skeleton_03

<Banned>
29,948
29,763
What specifically is making Cad's code hard to understand? Like he said this is just a simple exercise in nested loops.
I know that I will need to define letter to number ahead of time because he for sure wants that done so I need to figure out how to take those letter grades and fix them within the loop.

myOutput = myOutput.append("Student" + name + " had a GPA of " + studentGPA + ".\n")

I don't know what the append suffix is doing there, I assume it just means it is inserting variables and creating a string. I assume it is the same as below which is how I am used to doing it.

printf("Student %s had a GPA of %.2f this year.\n", name, studentGPA);