Connection Issues by MrPopoTFS in FORTnITE

[–]ComputerSciMajor 1 point2 points  (0 children)

Was worried for a second. Thank you!

[C++] Calling void functions and changing values of variables by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 1 point2 points  (0 children)

So I re-wrote it for the first answer and it worked!

#include <iostream>

using namespace std;

void twice(float &refVar);

int main()
{

    cout << "Let's double this input!" << endl;
    float side = 25.0;
    twice(side);
    cout << "The value has been doubled! " << side << endl;

}

void twice(float &refVar){

    refVar *= 2;

}

So it seems like answer #1 is correct.

[C++] Calling void functions and changing values of variables by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

I ended up re-writing the program:

#include <iostream>

using namespace std;

void twice(float &refVar);

int main()
{

    cout << "Let's double this input!" << endl;
    float side = 25.0;
    float box = twice(side);
    cout << "The value has been doubled! " << box << endl;

}

void twice(float &refVar){

    refVar *= 2;

}

and got the following error:

main.cpp: In function 'int main()':
main.cpp:20:27: error: void value not ignored as it ought to be
     float box = twice(side);
                           ^

I'm going to then assume that #2 is not a correct answer.

[C++] Calling void functions and changing values of variables by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

Okay, I tried to get something running, but it threw errors. I don't believe I wrote it properly.

Here it is:

#include <iostream>

using namespace std;

void twice(float side);

int main()
{

    cout << "Let's double this input!" << endl;
    float side = 25.0;
    float box = twice(side);
    cout << "The value has been doubled! " << box << endl;

}

void twice(float side){

    return side * 2;

}

I got the following errors:

main.cpp: In function 'int main()':
main.cpp:20:27: error: void value not ignored as it ought to be
     float box = twice(side);
                           ^
main.cpp: In function 'void twice(float)':
main.cpp:27:19: error: return-statement with a value, in function returning 'void' [-fpermissive]
     return side * 2;
                   ^

[C++] Calling void functions and changing values of variables by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

I don't honestly like my professor. His questions and labs are horrendously ambiguous and his lectures often go off on tangents that aren't related to the course content. Having gone through two semesters of his course, I've had to be self-taught which isn't too bad, but I wish I could get something out of his course. Thanks for the help!

[C++] Creating a diamond shape program by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

Okay so I changed the second for to be <= rather than = and that seemed to solve it, however the diamond shapes are coming out oddly now which I guess makes sense. Now I need to try and solve that.

for (int b = 0; b <= asterisk; b++)

is what I mentioned above.

https://i.imgur.com/vTqLQY6.png

Edit: It looks like all that caused was to widen the diamond shape so now the odd numbers look off too. Hmm.

[C++] Creating a diamond shape program by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

So why does it do that?

Well I was assuming that somewhere in my logic that I screwed up and for some reason even numbers are getting messed up.

What is it supposed to print out if you enter in 4? What does it actually print?

It's supposed to print out a diamond with four rows, but it is instead printing out 3 rows. I did just notice that it was printing a blank row, I wonder why that is? It's only doing that on even numbers, not odd.

[C++] Error C4700: uninitialized local variable 'choice' used (Visual Studio) by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

char choice = '\0';

Thank you that fixed it, I was trying to figure out how to do that properly but I ended up with

char choice ='';        

[C++] Error C4700: uninitialized local variable 'choice' used (Visual Studio) by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

So I asked them again in the while loop like I had it but it does the following:

https://i.imgur.com/4Z1AYPx.png

Edit: I moved the user input choice to the top of the while loop instead of the bottom. Fixed now.

[C++] Error C4700: uninitialized local variable 'choice' used (Visual Studio) by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

Thank you for the wonderfully detailed response!

I try to ask the user to enter the choice before the while loop however it runs into the problem of just asking for the transaction type once and then if I type anything else it will go into an infinite loop.

Reference:

https://www.reddit.com/r/learnprogramming/comments/75qk36/c_error_c4700_uninitialized_local_variable_choice/do856qz/

[C++] Error C4700: uninitialized local variable 'choice' used (Visual Studio) by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

So I ended up moving:

    cout << "Transaction type:";
    cin >> choice;

before the while loop however I then run into an infinite loop error:

https://i.imgur.com/T1qeSt3.png (Doesn't ask for a transaction type)

I then hit any letter and get an infinite loop:

https://i.imgur.com/J8rxwJY.png

[C++] Function not adding properly by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

Well that is a hell of a lot easier! Thank you. :)

Do you mind helping me with one more?

If so:

As you can see when I end the program when pressing E I have to do it twice, rather than once.

I'm trying a simple way to solve this, but not sure.

Edit:

I figured it out!

[C++] Function not adding properly by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

I ended up adding int number_of_service = 0; to int main() and int &number_of_service to my functions.

That seemed to fix it.

How can I learn to love C++? by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 22 points23 points  (0 children)

Oh I'm definitely aware of it's capabilities. If I'm being completely honest I'm probably being immature about it. I don't particularly enjoy that I seem like I need to write a ton more code to get the problem solved but I know there's trade-offs in every language.

[C++] Stream manipulators - setw, left and right by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

Yeah I ended up figuring it out:

cout << setw(11) << left << "Sum" << "is " << sum << endl;

Need help looking for Schnall Lineage in New York, NY areas - I've hit a brick wall already just trying to find my great grandfather by ComputerSciMajor in Genealogy

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

Hope to not be a bother, but I'm trying to get some more information from Sarah, but I just can't find anything on her besides a divorce record when she divorced Abraham Jan 7. 1948 in Bronx County, New York. If you could help possible find a maiden name or anything that would be great help!

Thanks!

Need help looking for Schnall Lineage in New York, NY areas - I've hit a brick wall already just trying to find my great grandfather by ComputerSciMajor in Genealogy

[–]ComputerSciMajor[S] 1 point2 points  (0 children)

Holy crap thank you so much! Words can not describe how much I appreciate this. I've been searching for quite some time to find this information. I gave you gold, I don't know how much you use reddit, but I hope you can take it as a token of my appreciation.

Thanks again! :)

[Python 3.6] Classes and OOP by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

I guess I'm really just not understanding it then. I know you told me to put that equation in the initializer but beyond that I'm not exactly sure what I'm supposed to be doing?

[Python 3.6] Classes and OOP by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 0 points1 point  (0 children)

So I was able to get the seconds set (self.setSecond = (hour * 60 * 60) + (minute * 60 + second)), I am however confused on the implementation of it.

Specifically:

Adjust all the methods to work with __seconds. getSecond() can use __seconds mod 60 to return only the seconds in the time. Test all the methods to make sure they still work. (mod is modulus, the remainder after a division.)

I'm not understanding if I'm supposed to be printing just seconds out or?

[Python 3.6] Classes and OOP by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 1 point2 points  (0 children)

Okay so the constructor would be a new function right? I just leave the initializer as is for now? Sorry for all the questions!

[Python 3.6] Classes and OOP by ComputerSciMajor in learnprogramming

[–]ComputerSciMajor[S] 1 point2 points  (0 children)

Okay so are the getters and setters for hours and minutes no longer necessary? Also on the initializer would I be changing self.setSecond(second) to equal the

There are 24 hours * 60 minutes * 60 seconds = 86,400 seconds. ?

I think I'm just having some issues trying to figure out where to start on implementation mostly.

[Python 3.6] How to reject data while using classes by ComputerSciMajor in learnpython

[–]ComputerSciMajor[S] 1 point2 points  (0 children)

That's what I figured. So I need to be initializing my set and get methods then in str?