#Needing help with program for class due in two days. (Code in chat along with givenfiles)

95 messages ยท Page 1 of 1 (latest)

trail caveBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

#

@tough breach

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

tough breach
#

here is my current code

#

Also the screenshots at the topic are in reverse order...

hollow escarp
#

what's your question?

tough breach
#

my question is how to even continue, i dont even know where to start with writing the while loop in main along with all the functions

hollow escarp
#

well first, what do you need to do?

tough breach
#

write main the main function that has the correct while loop

hollow escarp
#

and what's the correct while loop?

#

what does it need to do?

tough breach
hollow escarp
#

summarize it in your own words

#

like with bullet points or something

tough breach
#

the main function needs to
open the dino direct file and validate if it can be opene d
start the loop to read from the file
inside the loop it should increment the appropriate accumulator variable.
call the carn or herb func
open the correct file (carn or herb)
then call the printdino func
close the file
After the loop completes that read in all the data and printed the data to the output files, then you can close the
input file.

#

then

#

print the results to the screen

hollow escarp
#

good! Thank you :3

#

now, which of those steps are you stuck on?

tough breach
#

The start of the loop and down haha

hollow escarp
#

what does the loop iterate over?

tough breach
#

what do you mean ? im like a beginner beginner

echo kelp
tough breach
#

the file being the dino direct

echo kelp
#

so its iterating per line in the file?

#

per character?

hollow escarp
#

a loop usually does something until that condition is met. What is that condition?
Loops also can use a different value every time it loops over, this is called iteration

tough breach
#

yes because in the files the text is seprated by '#'

echo kelp
#

so are you iterating over each "chunk" of text

hollow escarp
#

so you're iterating over the strings delimited by #?

tough breach
echo kelp
#

i see

hollow escarp
#

are you able to write that loop that asks for the user to input what is required?

tough breach
#

do you mean like a cin>> ?

hollow escarp
#

if you need an input from the user directly, yes

tough breach
# echo kelp i see

the screenshots at the beginning explain what im trying to say in a much better way

hollow escarp
#

I haven't read them, and will not read them

#

if you can't explain them, you don't understand the assignment (and I'll help you understand it)

tough breach
#

i would say i understand and dont understand the assingment but i also dont think i am knowledable enough to even write the code if i fully understood the assingment

hollow escarp
#

you need to break it down into smaller chunks that you understand

#

then connect the chunks together to make the program

echo kelp
#

how limited is your knowledge in cpp

hollow escarp
#

that's not important tbh

tough breach
#

i learned how to use cout about a month and a half ago

#

so

hollow escarp
#

if it's the current assignment they need to do, they're knowledgeable enough

tough breach
#

like very limited

echo kelp
#

okay

#

have you opened the file with ifstream?

hollow escarp
#

do you think you can write the pseudo code of what you need to do?

tough breach
#

yes

tough breach
#

well

hollow escarp
#

it's a lot easier than writing the real code

echo kelp
#

then its going to be incredibly difficult if u cant even write the pseudocode for it

tough breach
#

ive got somewhat i need

hollow escarp
#

basically, write the code in english. For example:

while input is not valid:
  input = GetInput()
  if input is valid:
    break
tough breach
#

cout << "Dinosaur Directery File Name" ;
getline(cin, userin);

    while(userin ==  "dinoDirectery")
    {
        inFile.open("dinoDierectery.txt") ;
    }
    
    while(getline(inFile, tempstring , '#'))
    {

        
    }
    
    while (inFile >> dinoname) {
#

where the second while is is where i am truly stuck i guess

trail caveBOT
#
How to Format Code on Discord
Markup

```cpp
int main() {}
```

Result
int main() {}
tough breach
#
        getline(cin, userin); 

        while(userin ==  "dinoDirectery")
        {
            inFile.open("dinoDierectery.txt") ;
        }

        while(getline(inFile, tempstring , '#'))
        {


        }

        while (inFile >> dinoname) 
hollow escarp
#

what is the point of those loops?

tough breach
#

okay first one while the user inputs directery file the file opens

hollow escarp
#

why is it in a loop?

tough breach
#

I guess so i could validate input

hollow escarp
#

are you validating the input in the loop?

tough breach
#

i guess

hollow escarp
#

what are you doing if the input is not valid?

#

furthermore, what do you do if the input is valid?

tough breach
#

i would loop the getline

#

if input is invalid

#

so the user can input something again

hollow escarp
#

but that's not what this code does

tough breach
#

obvisouly

hollow escarp
#

why don't we start by fixing that then? ^^

tough breach
#

okay yes

hollow escarp
#

what are the steps that need to be done in that loop?

tough breach
#

would the getline be inside the while loop

hollow escarp
#

yes, we want to let the user make an input if what they entered is not valid

tough breach
#
        {
            getline(cin, userin); 
            inFile.open("dinoDierectery.txt") ;
        }
#

i guess whats confusing me here

#

is

#

wouldnt it be like while getline = dinodirect

#

then it would open the file

hollow escarp
#

you can do that, yes

#

you also want to re-ask for a different input when the input is not valid, not when it is valid, correct?

tough breach
#

how do i close this thread

hollow escarp
#

!solved

trail caveBOT
tough breach
#

!solved

trail caveBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity