WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

okay okay :cool:...so in the second loop I would call the function, no?

You really want us to write this for you, don't you.

The art of programming requires thought. I have not seen much thought on your part. It's just ask a question and hope you get the perfect answer.

The question you just asked is answered in the problem description you posted. Just as the previous question was. Now sit down with some paper and do the problem by hand so you understand how to solve the task. If you don't understand the problem, you can't program it. So work out how to solve the problem, then you have a better chance at programming it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

"Real code" is easier if you use an IDE. The IDE give you hints and suggestions.
Enjoy your studies.

"Real programmers" don't need an IDE. They actually know what they're doing.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

[boilerplate_help_info]

Posing requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]To [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

so the loops would look something similar to this:

for (x=0; x<=n; x++)
{....
    for (y=0; y<=x; y++)
    {  .....}
}

?

:) :cool:

:icon_smile: :icon_biggrin:

:icon_cheesygrin: :icon_mrgreen:

:icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

okay, I THINK I know how they are getting the values. I solved for y and got that y = ((user input)^2-(x)^2). Then you find each value for when x=0 up until x is equal to the user input. Does that seem right?

No. You are over-thinking it.
x goes from 0 to n.
For each x, y goes from 0 to x.

-x-  -y-
 0    0
 1    0
 1    1
 2    0
 2    1
 2    2
 3    0
  etc.
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1. the last line is cut off

What causes you to exit the loop? Have you already output all the data when it exits?

2. not sure if i need to have < 20 or <= 20 for the limit.

Then you'll have to make a decision... There's an easy way to find out :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

anyone?

Don't be so anxious. This is a Forum of volunteers, not a 24-7 teaching site.


Your formatting looks very good. I'd add a few more comments explaining what's happening. And the comments you have IMO should be more like:

case 2:                   //subtraction

Next, change the program to to print the answer with one print instead of 4.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I would love to use something like that, it seems easier; but instructions were to use A class linked list. I have a piece of code that I think will traverse thru my list, does it seem right?

listNode *current;   //pointer to point at each node

current = head; //points to beginning of list

while(current != NULL)  //loop to go thru

{

     current = current->next;

}

Yes.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

since you probably want persistence, I would go straight for an embedded postgresql database, or use the embedded database sqlite3. but only if you have time to do a bang-up job.
the language autoit(autoit3) at autoitscript.com has sqlite3 and it's a form of basic and it's easy to write a GUI.

I'm sure the instructor is looking for exactly this level of programming. He's probably going to teach Oracle and AI next week. :icon_rolleyes:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The thing I'm stuck on is how they are getting these x and y values

Oh?

... for integers x and y from 0 to n where y <= x.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Reread my previous post. You just mentioned like 4 different tasks. None of them are the basic tasks I mentioned. Have you finished those already?

And how long were you at your desk designing?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can you do the problem without the computer? Just sitting at a table on paper?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

When is i ever <= 0?

I assume you didn't bother with my post....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The 2nd ammendment exists in part to allow the citizenry to defend themselves against an oppressive government trying to take away their constitutional rights,

Bull! 2A has nothing to do with protection against the government itself.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes,WordPress is the best for blogging and build sites,It's easy to use.I have created 3 blogs in WordPress.

How many other systems have you used? Which ones? What were their drawbacks?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sit at your desk with the program.
Follow the program line by line with pencil and paper.
Write down the results of each statement.
Fill in variable contents as they change.
Draw another node for each malloc() .
Write the output in a separate place (acting as your screen) for each printf() Be very careful and do EXACTLY what each statement says to do, NOT what you meant it to do.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I just looked at your other threads. You certainly like to make us find out what's going wrong rather than simply telling us. Looks like you need to read the
[boilerplate_help_info]

Posing requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The problem is we have no idea
1) what the output is supposed to be
2) what output you actually got.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Learn assembler.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sit down at your desk with pencil and paper with the above explanation.

Start by figuring out how x and y work together to get the chart (forget the function for the moment). What happens to y as x changes and vice versa. How can that interaction be defined as a loop or loops?

Program that portion to get it working.

Then start adding the function.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Are you sure you are supposed to find if a word can be made from the letters and not simply find the dictionary word if it exists in the guess word?

IOW, if the word is CREATE you can certainly find EAT. But are you sure you need to find TAR RAT and ART too if they are in the dictionary?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

malloc() is designed to be used with C new is used with C++

Therefore, if you are writing C++, use new

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This is the code I am using and is not working.

Then you did something wrong. Since you didn't bother to explain what "not working" means, that's all we can say.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This question has been asked over 10 times (that's as high as I counted). Try using the forum SEARCH "VB send email"

Or leave the search box blank and hit SEARCH to get into advanced search.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What?? Even I didn't understand what you guys said!

You are printing the address of the pointer to the string.

address 65521 contains the pointer to the string "one"
address 65525 contains the pointer to the string "two"
address 65529 contains the pointer to the string "three"

Change the line to be: printf("%u %u \n",&argv[i], argv[i]); or better yet printf("%p %p \n",&argv[i], argv[i]); since you are displaying addresses. argv[i] is the value you are looking for.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need to do a lot more desk work designing the program. You cannot design, write code, and think all while sitting in front of the computer.

Away from the computer, write down the description of the task one line (sentence) at a time.
Take the first sentence and break it down into smaller pieces, or tasks, that need to be done. Do this for each sentence until you have a list of individual tasks.
Put each small task into an order that makes sense so if you gave the list to someone they could draw the pattern just by following the instructions you gave them.
Now, look at each task -- write down an explanation of how it would be coded.

The above is how programming is really done. 80% of the work is non-computer designing and planning, 15% is typing in the code, 5% is looking for the typos when it doesn't compile.

Once you get it to compile, the last 90% is debugging. :icon_wink:
This is where you follow the program with your design and figure out where
1) the code doesn't follow what you designed
2) where the design was wrong

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Start by creating a menu and inputting some data.

Next, add writing the data file.

Then read the data file and input more data.

Sit at your desk and continue designing the program piece by piece. When done with each piece, add it to the program.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Create a batch file that executes the program on each .txt file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Not necessarily easiest, but it would work just fine.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Anytime :icon_twisted:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First and foremost, learn to format your code. It's terrible and unreadable.

Second, asking for help using lol, idk, XD, and x.x gives us no information other than you spend too much time talking to the computer and not with real people. These are unnecessary and annoying computer geek jargon.

Third, you obviously didn't sit at a desk with pencil and paper to analyze the task to be accomplished. The more you understand the task, the easier to program it is. That means if it takes you 6 hours to program something start to finish,
a) the first 3-1/2 hours is at a desk understanding the task and planning the code,
b) 30 minutes programming the code,
c) 2 hours running and debugging to make the code perfect.

I remember one programming task I had I spent 4 hours understanding and planning the code, 15 minutes typing to code in, and 2 minutes fixing the one and only error - a typo. Any guess how long it would have taken if I sat down at the computer and just started programming?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I already gave you the solution. You still went elsewhere to use someone else's code. Is Accelerated C++ teaching you to steal other people's code to do the project or are you supposed to actually think and come up with your own solution?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

There's nothing magic about reading your magic numbers.
1) Open the file in binary.
2) Read as many bytes as you need for your test.
3) Test the bytes for the correct values.
4) done...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How about something simple like

cout << "                      Data On Spheres CS215 Sec" << endl;
cout << "                                 By," << endl;
cout << "                            Kris Armstrong" << endl;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK, that's what is supposed to happen.
You didn't explain what your code does.

Post each function and explain the steps each function takes to achieve the results desired.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please explain how the LOG and PrintLOG functions are supposed to work.
Then explain how the code you wrote for them work.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sort the values
Copy only the first of any duplicates to a new array.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sorry, I didn't realize your floats were being read into character arrays. Of course they should be read into floating point values, not characters! Doh!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Major problem #1
Executable code does NOT go in a header file. They go in .C file
Variable definitions do NOT go in a header file. They go in .C file

I'd fix these items first.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well, where do you need to calculate the circumference and volume? There are three choices:
1) Before you set the radius
2) After you set the radius and before you output answers
3) After you output answers
Choose wisely.

Now, where in

//***********************************************************************
// Print values in decimal, binary, hex and scientific
//***********************************************************************
for(int i=20; i<31; i++)
sphere::SetRadius(i)
printDecimal(i);
printBinary (i);
printHex(circumference);
printScientific(volume);

is that spot?

And don't forget to put your braces in the proper positions to get the loop correct.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The telltale sign of a student programmer is a statement like

if(id >= MINID && id <= MAXID && exam1 >= MINEXAM && exam1 <= MAXEXAM &&
exam2 >= MINEXAM && exam2 <= MAXEXAM && exam3 >= MINEXAM && exam3 <= MAXEXAM)
    return true;
else
    return false;

Which is mostly unreadable.
Split the statement into multiple IFs and return false if any IF is FALSE. If they are all good, return TRUE.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Instead of outputting a SPACE, add it to a string.
Before outputting a *, output that string.
Be sure to reset (clear) the string after output.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

He said define the data layout. Add methods to load and retrieve the data elements. Add methods to read and write the data elements.

Try this:
Make sure NAME is your first data element.
Write the class
Immediately write the string "<END OF CLASS>"
Examine at the file in binary.

Make your changes to the class.
Do the above again.
Compare the first file to the second.
If the files are identical, the changes do not affect your file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The errors you described above were just typos. The original while loop was deleted but it was basically the same thing.

You've now seen that posting code that has typos because you didn't bother to check them wastes your time and ours.

My problem lies in that I don't know how to get strings and doubles from a text file

Yes you do. Your code does that.

My original code did compile and opened the file properly but when it entered the loop the program would respond.

Respond with what? If you don't give us the details to make us understand, you're going to waste even more time with us giving half answers and confusing help.

I'm not sure what you mean about not reading in the first letter. Thanks for any support.

What does fgetc(inputFile) do?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If I have one key condition that is let's say a gamebreaker. Ie money = less than 0, does everything else then go in a big while loopn which may contain many more while loops and if else statements.

Yes

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why are you reading the first letter of the metal in the while statement? Do you really want the strings to be
luminum
ast-iron
ngot-iron
alleable-iron
ngot-steel
opper
ickel ?

Compare the file handle in these two statements: while (fgetc(inFile) != EOF) != NULL) fscanf(inputFile, "%s", &metalName); I'll bet the program never enters the loop, rather than gets stuck in it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am having a couple of problems. I think I got the formatting down for the most part. I am having issues in a few calculations and how to iterate through them. Basically I need to take the radius and calculate the circumference and the volume. Once I have the calculation I need to print them Radius in Decimal and Binary, then circumference in Hex and finally volume in scientific notation.

Questions.
1.) where would be best to declare circumference and volume?

What do you mean declare?

2.) once they are declared whats the best place to do the calculations?

After you decide you have the info you need to make the calculations.

3.) I can't see an array for this assignment so how would I do this for radius values of 20 - 30.

So make one if you think you need one. Or calculate and print each value as you go through the loop if you don't need an array.

Please see the attached code.

400-500 lines of code? I don't think so. Try posting only the parts you are having trouble with. Make it a little easy on us.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Where do you change angle[k] during your loop?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need more parentheses in your equation.
is (b-a/a-c) supposed to be
1) (b-(a/a)-c)
2) ((b-a)/(a-c))
3) ((b-(a/a))-c)
etc.

What you have is #1...