r/programminghelp • • Nov 23 '20

Processing I'm trying to parse webpages for their ad links... Any ways to filter what is and isn't an ad throughout the HTML?

4 Upvotes

I've got a simple crawler set up in python that can look through the a tags and follow the hrefs, but I'm only interested in following the ads. Is there any simple way to find what is and isn't an ad? My unfamiliarity with web dev may be showing here. Any help is appreciated.


r/programminghelp • • Nov 22 '20

C# Charts in C#

4 Upvotes

How can I import data from cvs or xml to a chart I c# Net framework? Thank you for your answers


r/programminghelp • • Nov 21 '20

Answered OOP Rock, paper scissors c++

4 Upvotes

Hello. My code isn't working. Idk what is wrong. The errors seem weird. I was wondering if someone can have a look and explain what I did wrong. Thanks. :)

Error list

main.cpp

User.h

User.cpp


r/programminghelp • • Nov 20 '20

JavaScript Working on my Capstone, looking for guidance. (Any/all appreciated!)

4 Upvotes

Hello all,

I'm not sure if this is the best place to post this being that I'm not the most familiar with reddit so if this isn't the correct place feel free to point me in the right direction..

I'm trying to create a blog for my capstone using react/next.js, contentful, d3/svg animations, and scss/css and I'm looking to recreate the animations/format of this portfolio page for my blog, https://www.signesduquotidien.org/, and I'm having trouble trying to figure out a starting point of trying to figure out what sort of events I would need to work on. The site itself looks to be made with jquery and scss but I'm looking to use react/next.js instead. Is anyone familiar with these types of animations or any library or source that might help me figure it out?

Any/all help will be greatly appreciated! Thank you!


r/programminghelp • • Nov 13 '20

Other How could I go about making a program that counts individual mouse clicks?

4 Upvotes

Not like those ones where you click one specific spot, but like counting overall clicks regardless of where, and maybe allows you to reset said count. Sorry if this is too specific, but I just need this for a mapping project I'm working on, and I don't want to go crazy mentally counting each of the thousands of clicks. Any feedback is greatly appreciated!


r/programminghelp • • Nov 09 '20

Other Algorithm (pseudocode and flowchart)

4 Upvotes

I am confused with a problem that asks to create a program that extracts and adds the two least significant digits of an integer. It does not provide a specific integer so any given integer will do and it is asked to create a pseudocode on how to get it. I have tried dividing a certain number by 10 and 1 to get the two least significant digits but it doesn't have the correct outcome. Will someone be so kindly help and explain it to me.


r/programminghelp • • Nov 05 '20

Answered Operator Function error (=)

4 Upvotes

https://imgur.com/a/G6ab4oI

I don't know what the issue is.

It says "expression must be a modifiable lvalue".


r/programminghelp • • Nov 01 '20

C++ What is the problem with MIN-line

4 Upvotes

So hi, it's me again, the wannabe-beginner coder idiot. Greetings!

So off to another problem I am having.

In this "program" if you will, you give an X amount of numbers. The "program" then sums them up, prints the sum, prints the mean of those numbers, and then it should print the biggest and smallest of the given numbers. As you can see in the code, I guess.

Except, it doesn't.

It gives me only the biggest, which is defined as MAX. As MIN, it also gives me the result of MAX.

#include <iostream>
#include <conio.h>

using namespace std;

int main(void)
{

	//variables
	int counter = 0, amount, number, sum = 0, mean = 0, min = 999, max = 0;

	cout << "How many numbers do you want to input?  ";
	cin >> amount;

	while (counter < amount)
	{
		cout << "Give me a number" << counter + 1 << " ";
		cin >> amount;

		sum = sum + number;
		mean = sum / amount;
		counter = counter + 1;


	}
	if (amount < 0 || (number + 1) < 0 || sum < 0 || mean < 0)
	{
		cout << "Well it's big fat fucking ERROR!";
	}
	else
	{

		cout << "Sum of the given numbers is " << sum;
		cout << "\nMean of the given numbers is " << mean;
	}
	if (number < min)
	{
		min = number;
		cout << "\nSmallest number is " << min;

	}
	if (number > max)
	{
		max = number;
		cout << "\nBiggest number is" << max;

	}


	_getch();

	return 0;
}

So, I ask you, the wise of the r/programminghelp:

Where's the poop?


r/programminghelp • • Oct 30 '20

Answered How do I input a value and them input another value once that has been inputted?

4 Upvotes

Hi

I want the program to ask the user for the name, then for the user to enter their name. Then once that has done the program asks the user for their number and then the user enters the number. The program then passes the inputs in a function.

It currently asks them for their name and number at once and then they can input once.

https://imgur.com/a/o5D2I7X

https://imgur.com/a/E1y2lbq


r/programminghelp • • Oct 29 '20

Other Where is the default gradle build output directory?

4 Upvotes

I'm trying to compile some kotlin code and the build works fine except I don't know where the output directory is.


r/programminghelp • • Oct 24 '20

Answered initiating values in the constructor

4 Upvotes

Hi,

I am trying to initialise values in the constructor but I get an error. It says class "BankAccount" has no member "accountNumber". I don't know why as I've set it as public in the header file.

cpp file:

#include "BankAccount.h"

#include <iostream>

#include <string>

BankAccount::BankAccount(unsigned long accountNumber, string accountName, int balance)

{

`this->accountNumber = accountNumber;`	

};

Header File:

#pragma once

#include <string>

using namespace std;

class BankAccount

{

public:

`BankAccount(unsigned long accountNumber, string accountName, int balance);`

`~BankAccount();`
`int GetBalance();`

`bool Withdraw(int value);`

`bool Deposit(int value);`

};


r/programminghelp • • Oct 18 '20

C# New to C#. Getting the error Operator '!=' cannot be applied to operands of type 'bool' and 'int'

4 Upvotes

My code is:

//I get the error here. Dog, sound, and food are all int.

while(dog != sound != food) { Console.ReadLine(); }


r/programminghelp • • Oct 10 '20

C++ Can someone help me with this I understand the whole if/else statement with the logical operators but don't understand how to calculate the total with the $5 promotional amount

4 Upvotes

Pseudocode for Chapter 4 assignment.

Show to the user what the program will do. Ask the user how many games he/she purchased Accept the input from the user Start if/else if the user purchased 0-1 games, add $10 the gift card PLUS the $5 promotional amount else if the user purchased 2-4 games, add $20 the gift card PLUS the $5 promotional amount else if the user purchased 5-9 games, add $40 the gift card PLUS the $5 promotional amount else if  the user purchased  10 or more games, add $10 the gift card PLUS the $5   promotional amount (optional) else if a player entered an invalid number, output an error message End of if/else Calculate the total amount added to the gift card Display the total dollar amount added to the gift card for the user (output the variable that contains the result from your calculations)

This is what I got so far

include <iostream>

using namespace std;

int main()

{

//variables

int games_purchased;

//How many games did the user purchased within this month

cout << "\nHow many games did you purchased this month: ";

cin >> games_purchased;

//Line break

cout << endl;

//Amount of giftcards given for each game purchased within the month

if ((games_purchased == 0) || (games_purchased == 1))

cout << "$10 gift card earned\n PLUS a $5 promotional amount ";

else if (games_purchased >= 2) || (games_purchased <= 4))

cout << "$20 gift card earned\n PLUS a $5 promotional amount ";

else if (games_purchased >= 5) || (games_purchased <= 9))

cout << "$40 gift card earned\n PLUS a $5 promotional amount";

else if (games_purchased >= 10)

cout << "$10 gift card earned\n PLUS a $5 promotional amount";

{

cout << "UH OH! A number 0 or greater must be entered.";

cout << "\nPlease rerun the program and try again.\n";

}

return 0;

}


r/programminghelp • • Oct 07 '20

C Shipping Calculator in C Programming

4 Upvotes

Hi, currently doing a Coding assignment and my professor has provided test cases to check with our program to make sure it is correct. My program is doing great besides one of the test cases. So I will include the instructions for the assignment, my code, and then what I need help figuring out.

_________________________________________________________

The Speedy Shipping Company will ship packages based on how much they weigh and how far they are being sent. They will only ship small packages up to 10 pounds. You have been tasked with writing a program that will help Speedy Shipping determine how much to charge per delivery. 

The charges are based on each 500 miles shipped. Shipping charges are not pro-rated; i.e., 600 miles is the same charge as 900 miles; i.e., 600 miles is counted as 2 segments of 500 miles. 

Here is the table they gave you:

Package Weight                                            Rate per 500 miles shipped

2 pounds or less                                                                    $1.50

More than 2 but not more than 6                              $3.70

More than 6 but not more than 10                            $5.35

____________________________________________________

Thats the assignment now here's my code.

_______________________________________________________

#include<stdio.h>

#include<stdlib.h>

int inputDistance() //Distance Value

{

int distance = 0;

do {

printf("Enter the number of miles as a whole number: ");

scanf_s("%d", &distance);

if (distance <= 0)

printf("\tError: Miles must be greater than zero!\n");

} while (distance <= 0); //Holds the Distance Value for later

return distance;

}

double inputWeight() //Weight Value

{

double weight = 0;

do {

printf("Enter the weight of the package in pounds: ");

scanf_s("%lf", &weight);

if (weight <= 0 || weight > 10)

printf("\tError: Weight must be greater than zero!\n");

} while (weight <= 0 || weight > 10);

return weight; //Holds the Weight Value for later

}

double calculateCharge(double weight, int distance) //Values to Calculate the price of shipping

{

double charge = 0;

if (weight <= 2) //Makes sure the charge is valid

charge = 1.50;

else if (weight <= 6)

charge = 3.70;

else

charge = 5.25;

int segments = distance / 500;

if (distance % 500 > 0) //Updates the segments per the condition above

segments += 1;

return charge * segments;

}

int main() { //Main Function

int ch = 0; //Variables below

int distance = 0;

double weight = 0.0;

double charge = 0.0;

do {

distance = inputDistance(); //Heres where the magic happens and you input the Distance & Weight

weight = inputWeight();

charge = calculateCharge(weight, distance); //Goes back to function above to calculate the charge

printf("The cost to ship your package is: $%.2f\n", charge); //The Results of The Shipping Charge

printf("Enter 1 to continue or 0 to quit: "); //Asks users if they would want to continue

scanf_s("%d", &ch);

} while (ch == 1);

printf("Good-bye!\n");

return 0;

}

_______________________________________________________________

Now heres the test case my professor assigned that is not matching.

Test Case 4:

Weight:            8.5 pounds 

Miles:              12345 miles                            (This is twenty-five 500-mile segments.)

Expected result: 

To ship a 8.5 pound package 12345 miles, your shipping charge is $133.75.

___________________________________________________________

Now my problem is that whenever I run my program and enter those values I get $131.25 for some reason and for the life of me I cannot figure out where my program is messing up. PLEASEEEE help me figure out what I am doing wrong


r/programminghelp • • Oct 06 '20

C++ How to get trailing zeroes without using setprecision

4 Upvotes

Im working on a project that requires me to do basic arithmetic functions on x and y. My teacher wants us to display 0.0 when doing something like 3.0 - 3.0. The x and y variables are double. I know double automatically displays 0. Is there a way to have the double display 0.0 without using setprecision?

Thank you


r/programminghelp • • Oct 05 '20

Other #frama-c

4 Upvotes

Can anyone provide some programs on loops using frama-c lang!!!


r/programminghelp • • Oct 03 '20

C GLib warnings with custom type

4 Upvotes

Currently, using a node results in this error:

(openmic-cli:483414): GLib-GObject-WARNING **: 17:19:59.634: invalid unclassed type '(null)' in class cast to 'OpenMicNode'

In the openmic-cli executable, this causes a segfault. The warnings come from these lines and files:

  • src/lib/node.c:82

  • src/lib/node.c:93

  • src/lib/node.c:94

The segfault in openmic-cli comes from the openmic_context_build_treev when the nodes are attached.

Note: I suggest looking at the GitHub issue for updates as its easier there than here.

GitHub: https://github.com/MidstallSoftware/openmic

GH Issue No.: #1


r/programminghelp • • Sep 27 '20

Java What does it mean to return in a java program?

4 Upvotes

This may seem like a stupid question but i'm trying to understand better. I'm writing methods in java rn and the problem i'm working on says that it should not return anything which would make it a type void. I would assume that not "returning" something would mean that when you call the method nothing would happen but that wouldn't make sense at all. Can someone explain this? Thanks in advance!


r/programminghelp • • Sep 20 '20

Python What is the difference between dictionary1["type"] and dictionary1.get("type")?

4 Upvotes
dictionary1 = {
    "type": "type"
}

Say I have a dictionary. What is the difference between the following methods of grabbing information from it?

dictionary1["type"]
dictionary1.get("type")

r/programminghelp • • Sep 18 '20

C# C# Unity: Checking if an object is null before trying to use it, and the object still throws a MissingReferenceException?

4 Upvotes

Like the title says I'm working with Unity and C#. In unity I'm trying to have objects keep track of neighboring objects in a list, and when a neighboring object is deleted to remove them from the list. I keep having if(circuitObject == null) return; in the beginning of my functions that deal with these neighboring objects but it doesn't seem to be working. I still get MissingReferenceExceptions.

Before I delete each object I ask all of it's neighbors "Delete this object from your list, then make sure your list doesn't have any null references" through the following code:

public bool RemoveSelf()
    {
        if (!canDelete) return false;

        foreach (CircuitItem ci in NeighborList)
        {
            ci.RemoveFlow(this); // Remove from the other neighbors neighborList
        }
        
        Destroy(gameObject); // Delete this GameObject
        return true;
    }

public virtual bool RemoveFlow(CircuitItem ci) {
        // I was having issues where List.Remove(GameObject) would sometimes remove the wrong GameObject
        if (ci != null)
        {
            List<CircuitItem> tempList = new List<CircuitItem>();

            for (int i = 0; i < NeighborList.Count; i++)
            {
                if (NeighborList[i] != ci && NeighborList[i] != null)
                {
                    tempList.Add(NeighborList[i]);
                }
            }
            
            NeighborList = tempList;

            return true;
        }
        return false;
}

This seems super inefficient but using List.Remove(object) was often removing the wrong object. I also have a solution that kept track of each index of objects in each list but that created a lot of overhead. The error comes in during the DiscoverFlow(CircuitItem) function which is called anytime an object is initialized, it will ask each of it's neighbors to try and discover it

public int DiscoverFlow(CircuitItem input)
    {
        if (input == null) return badFlowIndex; // I check if it's null
        
        if (flowChecking.Contains(input) && input.FlowCheck.Contains(this) && flowChecking.IndexOf(input) != badFlowIndex)
        {
            return flowChecking.IndexOf(input);
        }
        
        Navigation.Direction dir = Navigation.DirectionBetween(transform.position, input.transform.position); // RIGHT HERE I KEEP GETTING THE ERROR THAT IT'S NULL
        
        //Rest of the function
}

That last actual code line specifically at input.transform.position I get the error:"Object of type CircuitItem has been destroy but you are still trying to access it. Your script should check if it's null or you should not destroy it"But I am checking if it's null. It doesn't get caught by my conditional, so why? Is there something I don't understand about how Unity destroy's things? Is there something I don't understand about C#'s null value? How does it keep skipping the if(input == null) return badFlowIndes; but still throw a statement that it's null?

Second question: in the RemoveSelf() function, I inconsistently run into issues where the object is deleted before it's removed from other object Lists, I tried to do while(ci.NeighborList.Contains(this)) ci.RemoveFlow(this); but that creates an infinite loop. I can't figure out what is wrong with my RemoveFlow function. It looks like it should be removing the object properly.

Edit: messed up 2 variable names


r/programminghelp • • Sep 09 '20

C Bash error just trying to make a hello world program run

4 Upvotes

Hi,

This is pathetic as I've done it on before, however I'm following a Udemy (link if you may have experience, lecture 19) tutorial and run into a issue.

Been quite a convoluted set-up using Code::Blocks and Cygwin while using VisualCode and got an error just trying to make the hello world message run via terminal:

****@****/cygdrive/c/Users/****/projects/helloworld

$ ls

helloworld.c helloworld.exe

****@**** /cygdrive/c/Users/****/projects/helloworld

$ helloworld.exe

bash: helloworld.exe: command not found

I can't work out where I'm going wrong. I've reviewed the entire video for my own errors and it isn't working. The code itself is fine. No errors. Is it something to do with the installation? Will I need to do the set up again?

Thanks for any help


r/programminghelp • • Sep 06 '20

C Need help with Visual Studio Code

4 Upvotes

I started my programming design class where we will learn C and my TA told me to use Visual Studio Code to write everything and I have to say it looks pretty cool. The only problem I have though is it doesn’t show errors. I did download the pack that lets you see the colored text but I feel like I need to see the errors while I’m writing. Is there anyway to add that feature or no?


r/programminghelp • • Sep 02 '20

Python SQLite Database Query

4 Upvotes

Hey all,

I'm creating a little fun project of a macros tracker using Python GUI modules and SQLite3.

One part that i'm stuck on and have tried to ignore it for days is inputting information to a database using a dropdown box.

For example the dropdown box could have: chicken

mince

chocolate

Now if I select one of these and click submit, I want the submit button to input the selected item (e.g chocolate) along with it's macros (protein, carbs, fats) to a new database.

At present I can only send the name to the new database and not the other macros alongside it.

Any help would be great,

Many Thanks


r/programminghelp • • Aug 19 '20

Other Need a good laptop for programming

4 Upvotes

I just started school for cyber and information security technology (cis) for short and I need a good laptop when I start doing coding and stuff but my budget is $1,000 can anyone help me