r/programminghelp • • Nov 17 '19

Taxes.java:21 error: illegal start of expression ....... How is that an illegal start of the expression!!!! Just started working with multiple methods and I'm don't understand what I'm doing wrong ๐Ÿ˜” help pwease ๐Ÿ’œ

Post image
4 Upvotes

r/programminghelp • • Nov 08 '19

Finding it hard to understand programming

4 Upvotes

Hi there! Hopefully this is the right place for this, but Im currently in first year university doing software engineering but I'm finding it rather difficult to understand basic concepts of programming or even where the hell to start when wanting to try to creat something at home. I am using CodeAcademy outside of uni to help but I still struggle to understand it and it's getting to the point of wondering if programming is even for me. Would anyone have any ideas on how I could improve understanding programming because I really want to learn it and have a career with it in the future but I just can't get my head around it.

Anything would be helpful, I just don't want to get discouraged from wanting to do programming.


r/programminghelp • • Sep 14 '19

Can someone walk me through some JavaScript code?

4 Upvotes

I just would like to know ecactly what the difference is in the reject(error) and resolve(error):

exports.post = (url, body, authorization) => {
return new Promise((resolve, reject) => {
const options = setOptions('POST', url, authorization)
options.body = body
request(options, (error, response) => {
if (error) {
reject(error)
} else {
resolve(response)
}
})
}) // return Promise
}

I'm not very good at JavaScript and a walk through of what's happening would be greatly appreciated!


r/programminghelp • • Aug 23 '19

How hard would it be to program a game from scratch comparable to Atari 2600 level of sophistication? (Ex: Adventure, Pitfall, Kaboom?)

4 Upvotes

Hey programmers, this might be too lofty, but I would love to build a very basic, buggy, but fun game thatโ€™s literally pre 1980s game technology, how hard would it be to program the game from scratch like Adventure, Kaboom, Pitfall?


r/programminghelp • • Aug 10 '19

[JS] localStorage help

4 Upvotes

function save() {

document.getElementById("deets").innerHTML = "saving your settings..."

document.getElementById("loading").style.display = 'block'

if (document.getElementById("lang").value === "en") {localStorage.setItem("lang", "en")}

if (document.getElementById("theme").value === "T1") {localStorage.setItem("theme", "T1")}

if (document.getElementById("theme").value === "T2") {localStorage.setItem("theme", "T2")}

document.getElementById("deets").innerHTML = ""

document.getElementById("loading").style.display = 'none'

document.getElementById("settings").style.display = 'none'

document.getElementById("successSettings").style.display = 'block'

setTimeout(function () {

	document.getElementById("successSettings").style.display = 'none'

}, 3000);

}

function applySettings() {

document.getElementById("deets").innerHTML = "applying settings..."

document.getElementById("loading").style.display = "block";

if (localStorage.getItem("lang") === "en") {document.getElementById("lang").value = "en"}

if (localStorage.getItem("theme") === "T1") {document.getElementById("theme").value = "T1";}

if (localStorage.getItem("theme") === "T2") {document.getElementById("theme").value = "T2"; whiteMode();}

document.getElementById("loading").style.display = "none";

}

Is there anything wrong with this code? I've been trying it for a while through Firefox and it won't save the cookies :/


r/programminghelp • • Jul 27 '19

(Java) how do I get an int from one method to another?

4 Upvotes

The goal of the code is to write a program using 2 methods. The two methods sould be given an objects weight on earth and convert it to the given weight on mars and the moon.the program must prompt for the user to input the value. I've created 2 different methods. (The earth method containing the user input value,and the main method containing the finally result which is how much a person weighs on both the moon and mars) The problem I'm having is that when I try to run the code it says it is unable to find the earth method int e. My question is how do I get the users imputed int e into the main method? This is my code so far (also sorry for any weird formatting, I'm typing this on my phone)

`public static void main ( String [] args ) { double dmn = ((earth (e) / 9.81) * 1.622; //a persons earth weight on the moon

    double dmar = ((earth (e) / 9.81) * 3.711; // a persons earth weight on mars

    System.out.print ("your Earth weight on the moon is:  " + damn);

    System.out.print (" are Earth weight on Mars is :  " + dmar);

}

public static int earth (int e)

{ e = Input.getInt ("please enter your weight on earth: ");

} `


r/programminghelp • • Jul 10 '19

Need help picking a laptop for college.

4 Upvotes

I start community college next month (august) and one of my classes are intro to programming. I have no idea what ill need or how powerful of a laptop i will need. My price range is from $750-1200.


r/programminghelp • • May 17 '19

Is it ok to learn c# first?

4 Upvotes

Iโ€™m a beginner and Iโ€™m learning c# is c# to hard for me, or is it fine

just curious


r/programminghelp • • May 06 '19

Course on c++

4 Upvotes

Can someone suggest me some good resources to learn c++ from beginner to advanced.

I know how to program in python and wanted to do a project in c++. I am going to use a gcc compiler as I am using a linux system.

I also wanted to ask what is the difference in using different compilers(does the program syntax change)


r/programminghelp • • Mar 18 '19

How do I go from assembly code to an nes image/rom/playable game file?

4 Upvotes

I'd like to code in assembly, not C. How do I make my code into a playable file?


r/programminghelp • • Mar 07 '19

How to save many input strings as variables

4 Upvotes

-I'm new to programming, I've searched and couldn't find anything, yata yata yata-

PYTHON

The best way I can think of asking is by describing what I want the output to be:

-------

Enter John's line:

> Hi

Enter Jane's line

> Hello

Enter John's next line

> Sup

Enter Jane's next line

> STOP

---------

And I would like each of those, ad infinitum, to be labled as 'p1_line1' 'p2_line1' 'p1_line2' et cetera, without having to limit the amount of lines that can be written.

Bonus points if you explain the best way to recall them later :)


r/programminghelp • • Jan 08 '19

Python pip not working

4 Upvotes

I'm trying to install a module using pip but when I try to run pip commands through cmd, pip isn't recognized. I also can't use the 'python' command but can use the 'py' command which may or may or not be equivalent. I tried tweaking the PATH to make it work, but that did nothing and I don't know if I did it correctly. I am currently using Python 3.7 with no other versions installed. I am using Windows 10 64bit.

Edit: I seem to have gotten it working after fiddling with the path a bit more. I don't know why it works, but I'm not going question it further.


r/programminghelp • • Dec 05 '18

Im thinking about not going to my programming class anymore.

4 Upvotes

All semester ive been trying to understand this class but ive failed. I want to redo the course next year, maybe focus on understanding it over the summer. But i dont know if its a good idea. Please give me some advice,im really struggling.


r/programminghelp • • Dec 02 '18

Non programmer here just asking, why is it that almost all games include item stacking up to 99 or 999 but never 1000

4 Upvotes

Always been curious about it, might have something to do with bits? Like I said non programmer.


r/programminghelp • • Dec 01 '18

[Python] Running a pairwise test for every element in a list

4 Upvotes

I am running some stats on every pair in my list of datasets. E.g. array[0] versus array[1], array[0] vs array[2], etc.
Is there a good way to do this other than a nested loop?

Thanks!


r/programminghelp • • Nov 08 '18

Help with Linked List in Java?

4 Upvotes

Not going to lie, I'm working on a school lab, but im not surfing for solutions, just a little help.

TL;DR: How do I create a linked list of Objects and proceed to manipulate them?

Longer Version: I have five classes:

Game

Trivia extends Game

Static TriviaNode (inner class to Trivia)

Static TriviaLinkedList (inner class to Trivia)

TestTriviaGames (my test client)

It is required by the lab that I have the first four classes. I can create Trivia objects easily, but im struggling to get the objects into a linked list so I can test my methods I had to code to manipulate the list.

Im confused about the use of the TriviaNode and TriviaLinkedList classes. Are they required to actually make and use a linked list? Which class should be setting the head and tail? Should I be setting that in my test client?


r/programminghelp • • Oct 16 '18

How would I make a bot on reddit that would delete a post after a certain amount of upvotes, say 100, are gained? (For moderating a sub)

4 Upvotes

r/programminghelp • • Oct 14 '18

[C++] I'm trying to write a program that given a number and then the coefficients of a polynomial (from x^0 to x^n) gives the result of the polynomial when x=said number but it doesn't always work

Post image
4 Upvotes

r/programminghelp • • Sep 08 '18

Throws out error Compilation Failed. The brackets and text "kg" seem to trigger the error.

Post image
4 Upvotes

r/programminghelp • • May 19 '18

Arduino Spazzing

4 Upvotes

I'm trying to run an arduino robot that can pick up ping pong balls (bc why not), and when I plug the robot into the power source, all the servos are spazzing and not going/staying in the correct position.

Note: Servos A and B are continuous, meanwhile C, D, and E are 180 degree servos.

Code:

 //L293D
#include <Servo.h>

//Motors
const int motorAPin1  = 4;  // Pin 14 of L293D
 const int motorAPin2  = 5;  // Pin 10 of L293D
 const int motorBPin1  = 6;  // Pin 7 of L293D
 const int motorBPin2  = 7;  // Pin 2 of L293D


 //Servos
 Servo servoA;
 Servo servoB;
 Servo servoC;
 Servo servoD;
 Servo servoE;


 //Button
 const int buttonPin = 2;   // the number of the pushbutton pin
 boolean buttonState = false;       // variable for reading the pushbutton status

 boolean clawOpen = true;

 //Variables for Distance Sensor
const int trigPin = 13;
const int echoPin = 12;
long duration;
int distance;


void setup() {

  // put your setup code here, to run once:

  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  pinMode (A0, OUTPUT);

  //Set motor pins as outputs
  pinMode(motorAPin1, OUTPUT);
  pinMode(motorAPin2, OUTPUT);
  pinMode(motorBPin1, OUTPUT);
  pinMode(motorBPin2, OUTPUT);


  //Setting up the servos

  servoA.attach(3);//Continuous
  servoB.attach(8);//Continuous
  servoC.attach(10);//Middle 180
  servoD.attach(9);//Top 180
  servoE.attach(11);//Top 180


  //Distance Sensor

  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input


  //Setting default position for 180 degree servos

  servoC.write(90);
  servoD.write(90);
  servoE.write(90);

}

void loop() {

  // put your main code here, to run repeatedly:

  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 50 milliseconds
  digitalWrite(trigPin, HIGH);
  delay(50);
  digitalWrite(trigPin, LOW);

  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);

  // Calculating the distance in centimeters
  distance = (duration / 2) * 29.1;

  if (buttonState) {

    analogWrite (A0, HIGH);
    delay(1000);
    servoA.write(60);
    servoB.write(120);
    delay(500);
    servoA.write(90);
    servoB.write(90);
    delay(500);
    servoA.write(180);
    servoB.write(0);
    delay(500);
    servoA.write(90);
    servoB.write(90);
    servoD.write(135);
    servoE.write(135);

  } 
  else{

    analogWrite (A0, LOW);
    servoA.write(90);
    servoB.write(90);
    servoC.write(90);
    servoD.write(90);
    servoE.write(90);

  }

}

The code isn't finished because I can't get an accurate statement of if what I have so far is finished because of the servos not consistently doing what I want.


r/programminghelp • • Aug 24 '16

PROLOG CHATBOT

4 Upvotes

Hello, I'm planning to make a chatbot using prolog. I know a bit about prolog, but I have a hard time coding on a chatter. Do you have any sample? Anything is a big help. Thanks in advance.


r/programminghelp • • Apr 10 '16

Python, attempting to figure out why my code always rounds down instead of just using the given value.

4 Upvotes

I'm sorry for including all of the code instead of any tiny relevant bits, but that's probably actually useful. When you run the program and insert the variables, ARMROTS always is rounded down to the nearest whole number.

http://pastebin.com/33XhsvHX


r/programminghelp • • Jun 22 '15

Screen glitch bug in my java gameboy emulator

4 Upvotes

I have written a gameboy emulator in java after reading the pandocs for many weeks, and I understand the architecture of the console very well. Regardless of this, my final product has a screen glitch bug which distorts what is on the screen. (See: http://imgur.com/VWeFBQil.png)

The image in the link is my backup ROM of tetris for the DMG playing. The text in the middle is the Nintendo logo I believe, as when the emulator starts it scrolls down from the top. The header glitch above this is what I believe is the tetris game start screen background. There is no sound, joypad interrupts, or sprites implemented as I have spent all my time trying to get the background to display properly. Once that is done I will easily be able to shift over and work on those components of the system.

What I am asking is for anyone to attempt to help me find the issue with this project? I have spent 2 weeks attempting to fix this bug, to no avail. I have wasted too much time trying to find and fix it; it is affecting my home life!

Github repo: https://github.com/glen-mac/jBoy


r/programminghelp • • Aug 03 '26

Project Related Is bcrypt a good choice for hashing refresh tokens? I'm stuck with session lookup.

3 Upvotes

I'm building my own authentication system in Node.js, Express, MongoDB (Mongoose), JWT, and bcrypt. I'm trying to understand the architecture instead of just copying a tutorial.

My current flow is:

  • User registers/logs in.

  • Password is hashed with bcrypt.

  • I generate a refresh token (JWT).

  • I hash the refresh token with bcrypt before storing it in the sessions collection.

  • The actual refresh token is sent to the client as an HttpOnly cookie.

The problem appears during the refresh endpoint.

Since bcrypt generates a different hash every time, I can't do something like:

const refreshTokenHash = await bcrypt.hash(refreshToken, 10);

const session = await sessionModel.findOne({
    refreshTokenHash,
    revoked: false
});

because hashing the same refresh token again produces a different hash, so the session can't be found.

The tutorial I was following used SHA-256 for hashing refresh tokens, so searching by hash worked because SHA-256 is deterministic. I intentionally switched to bcrypt because I thought it would be more secure, but now I've run into this architectural problem.

I've thought about putting sessionId inside the refresh token so I can:

  1. Verify the JWT.

  2. Read the sessionId.

  3. Find the session by _id.

  4. Use bcrypt.compare(refreshToken, session.refreshTokenHash).

That seems reasonable, but creating the session first introduces another issue because my schema requires refreshTokenHash, while I need the sessionId before I can generate and hash the refresh token.

if anyone needs more info to tell me a solution just ask for it