Big Chungus
Member
recursion is kicking my ass
D:
D:
What's OO?
recursion is kicking my ass
D:
recursion is kicking my ass
D:
Object oriented. Once you wrap your head around the whats and whys you can adapt it to a lot of languages.
Is there any resource that teaches that? And isn't that something that's apart of C# and C++?
Recursion is the most natural way to think about most problems. What about it is giving you trouble?
I love me some recursion
They have only made 6 posts and they've all been spam, going back a year.
Any beginner book on an object-oriented language (Java, C++, C# to name a few) will thoroughly teach you OOP. And yes, C# and C++ are definitely very object-oriented.
recursion is kicking my ass
D:
Just learn Java.Well I'm currently going through the Javascript course at codeacademy, would that be enough or would it be best to use more resources?
Well I'm currently going through the Javascript course at codeacademy, would that be enough or would it be best to use more resources?
Well I'm currently going through the Javascript course at codeacademy, would that be enough or would it be best to use more resources?
I've always used VMware, do you prefer virtualbox?
I think vmware is probably better but I've just had nightmares with it over the years. Probably because I have not thrashed it as much, vb has been good to me![]()
Isn't Pi a constant?Anyone in C++ know the variable for the value of Pi (3.14....)? The book doesn't have it and I have to use it to do one of the equations/programs in the book.
Anyone in C++ know the variable for the value of Pi (3.14....)? The book doesn't have it and I have to use it to do one of the equations/programs in the book.
Isn't Pi a constant?
Anyone in C++ know the variable for the value of Pi (3.14....)? The book doesn't have it and I have to use it to do one of the equations/programs in the book.
There's no official constant for it, but you might find M_PI in math.hAnyone in C++ know the variable for the value of Pi (3.14....)? The book doesn't have it and I have to use it to do one of the equations/programs in the book.
You could define a constant with the double PI = 22/7. It's an approximation, but it will work.
Not in standard C++ or C from what I was able to gather.
I think under <math.h> it's listed as M_PI
or use atan(1) * 4 and cache it that way.
There's no official constant for it, but you might find M_PI in math.h
On Windows with Microsoft's headers there's a define you need to enable, too: _USE_MATH_DEFINES
I had to add the second scanner because it wouldn't let me type something in before in the command prompt.Scanner sc = new Scanner(System.in);
System.out.println("How many items do you want?");
order= sc.nextInt();
System.out.println("would you like express shipping?");
Scanner ans = new Scanner(System.in);
answer=ans.nextLine();
if (answer.equals("yes")){
//rest of code
we're making a cash register program as an assignment. anyway, my problem is that when making a case for store credit, i set tax to 0, price and total are the same value for this. everything is fine. everything is a double stored in the array. when i go to print, it prints out price and tax just fine, but it prints total as say 10.00 and then prints a memory address right next to it. only happens here, if i do a normal item everything is fine. setprecision doesn't help either. i know this is very vague, but i'm pretty upset about this
Show us some code. Sounds like you are outputting the address rather than the value at the address.
for(int i = 0; i < Size; i++
{
cout << MyArray.Price() << " " << MyArray.Total();
}
is there a reason it would only happen with the credit option though? its the same exact code for every other type of item, the only difference being that if it is credit that the tax is 0 and the total and price variables have the same value. i'm just printing it through a for loop
Code:for(int i = 0; i < Size; i++ { cout << MyArray.Price() << " " << MyArray.Total(); }
Price and Total are just functions that return the value of a private variable
is there a reason it would only happen with the credit option though? its the same exact code for every other type of item, the only difference being that if it is credit that the tax is 0 and the total and price variables have the same value. i'm just printing it through a for loop
Code:for(int i = 0; i < Size; i++ { cout << MyArray.Price() << " " << MyArray.Total(); }
Price and Total are just functions that return the value of a private variable
We need more code than that. What is MyArray storing? Is it an array of objects that you are using to store a transaction?
Is that an actual code snippet? Because you are missing an ending parenthesis in the for loop after i++ and you aren't even using the variable to traverse the array. Don't you need MyArray.Price() and so on...
Is that an actual code snippet? Because you are missing an ending parenthesis in the for loop after i++ and you aren't even using the variable to traverse the array. Don't you need MyArray.Price() and so on...
Noob question incoming:
Do I always have to initialize a new scanner if I want to read a different input from the user or can I use the same one?
Example:
And the main methods can't access instance variables? Only locals, right? Just want to be sure.
no, i just typed an example of my code. i really can't post it because they'll scan for plagarism crap. basically i call everything fine in the program.
there are four types of transactions that can be made. for the other three, everything works fine using the same method. for this fourth one, it just randomly prints a memory address after it prints the correct value. i'll probably have my teacher look at it tomorrow, it is just driving me crazy, sorry
c++, and the CurrentSize stores the size of the array(it is dynamic)
int myArray [3];
for (int i= 0; i < 3; i++)
{
myArray[i] = i;
}
for (int i = 0; i < 4; i++)
{
cout << " " << myArray[i];
}
no, i just typed an example of my code. i really can't post it because they'll scan for plagarism crap. basically i call everything fine in the program.
there are four types of transactions that can be made. for the other three, everything works fine using the same method. for this fourth one, it just randomly prints a memory address after it prints the correct value. i'll probably have my teacher look at it tomorrow, it is just driving me crazy, sorry
c++, and the CurrentSize stores the size of the array(it is dynamic)
Did you overload your transaction class constructor?
Can you post examples of the signatures and what you are passing in when creating a credit transaction?
Edit - try setting tax to 0.0 instead of 0
For the first time, I am almost completed with a game in Java (yay), but after this, I really want to learn C.
For some strange reason, Java is easy, Python is easy, and (6502) ASM is easy and fun from my limited time with it, but I am having problems learning C and especially C++. I have no idea what it is that bothers me about those languages...
Did/does anyone else feel that way?
Nope, I found both C ad C++ straight forward and simple while programming languages like Java to be bloated.
Although I'm now a Java programmer for a living, still prefer C++.
Did you start with Java? If you did I think C and C++ are quite difficult to wrap your head around. Pointers especially are a stumbling block for people going back.
Nope, I found both C ad C++ straight forward and simple while programming languages like Java to be bloated.
Although I'm now a Java programmer for a living, still prefer C++.
The things I had trouble with:For the first time, I am almost completed with a game in Java (yay), but after this, I really want to learn C.
For some strange reason, Java is easy, Python is easy, and (6502) ASM is easy and fun from my limited time with it, but I am having problems learning C and especially C++. I have no idea what it is that bothers me about those languages...
Did/does anyone else feel that way?
i'm trying to teach myself programming, but i don't have any previous experience. which would be an appropriate language for me to start with and lay a good foundation? thanks
What is the driver behind you learning?
In C, does anyone know how to make a void type function return a reversed string to main? I just can't get this working properly. And I can't use any string functions.
void reverse(char* s)
{
char* p = s;
int len = 0;
char c;
while (*p++)
len++;
for (int i = 0, j = len-1; i < j; ++i, --j) {
c = s[i];
s[i] = s[j];
s[j] = c;
}
}
I suddenly found myself giving a class on programing and I fell that my performance is less than satisfactory.
They are third year students on CS, so they are supposed to know their way around programming by know. So, the approach I took was to prepare examples on how to do things that I consider that are relevant in order to understand the language and paradigm (functional). I even code some traps inside my code in order to ask them questions like "Can anyone tell my why doing that is a bad idea? How can we improve it?" Yet, I barely get any feedback. I feel trapped in dull on a monologue, reading and trying to explaining line of code after line of code, without any hint if my explanation terrible.
Doesn't help that I didn't payed attention to my programing courses when I was a student, since I preferred a hands on approach. You can say I considered the courses I took almost as dull as my own.
Any tips, programming GAF?
I haven't tested this, but something like this should work.
Code:void reverse(char* s) { char* p = s; int len = 0; char c; while (*p++) len++; for (int i = 0, j = len-1; i < j; ++i, --j) { c = s[i]; s[i] = s[j]; s[j] = c; } }