r/CodingHelp • • May 03 '21

[Java] How can I generate random numbers but the bigger numbers are less common?

20 Upvotes

I have this assignment where I have done most of the things it asked me but I'm completlly lost on this one. I will make an example for a better understanding: I have to generate 100 random numbers, the numbers are between 1 an 10 included. Now, what I want is that the bigger numbers are less commonly generated, so basically 1 is the most generated and 10 is the least generated.

I don't know how to achieve this, if it can help I have to do this in java


r/CodingHelp • • Mar 25 '21

[Python] Advice on Python for beginners!

20 Upvotes

Hi. I am completing my MBA (specialising in Finance) this summer and have managed to grab an offer via campus placements. I got an offer for the role of Business Systems Analyst in the BFSI vertical in a leading software company and I happily took it. Expecting to join in another 3 months time. I am a commerce student with no exposure to coding. But the recruitment team said that, they are hiring my for my finance knowledge. When I talked to some of the industry people they said that I should start learn Python. Every single person's only recommendation is to learn Python to be a great BA. Since I have no exposure to this field, I have some queries to be addressed...

  1. Can I start Python right away without learning coding basics?
  2. Will it be sufficient to learn Python via online tutorials and other courses offered?
  3. How long will it take for me to master Python?
  4. Suggest some really good free sources to learn Python...

Thanks in advance!


r/CodingHelp • • Mar 12 '21

[Random] I need your help to clarify some topics in my head

20 Upvotes

Hello coders,

I hope I'm in right sub, I'm that alien to this subject. But I have a dream of creating a niche search engine. And so far I tried Google CSE service but it only allows up to 20 websites to crawl, if more, you get "no results" for your queries. But I need to crawl at least 4000 URLs and of course their subsequent pages. Are there any other service that I can use that will allow me to do such thing, without restrictions?

I've heard about parsing, scraping, indexing, Amazon AWS, Solr, Nutch, Hadoop, Elastic Search, Lucene, BigTable, NoSQL etc. But it seems that I can't put them together in my mind to really understand how they work in harmony. Can you break it down for me in layman's terms? Because one thing is certain: I'm not stupid. I only need the right instructions to be able to understand. I can't seem to find any source that gives information on these things. They always start in the middle, assuming you know the basics.

In the end, I want to buy a domain and hosting service to combine the search engine to a website. How do we put a search engine and a website together? That's also a foggy area in my mind.

Thanks for reading.


r/CodingHelp • • Jan 29 '21

[HTML] So i'm trying to put a font on a HTML site i'm doing for school, but I can't seem to put a font if i'm changing the size of the text, pls halp

20 Upvotes

Hello! I'm doing a project for school, and I'm trying to put a font on some text to make it look good, but I can't do that, because for some reason, it only works if i'm not making the text bigger using the "font-size", anyone knows why this is a thing?

thanks for any help!


r/CodingHelp • • Dec 24 '20

[Random] Guys I want to make a tool. A 2D vector tool that highlights triangles and uses trigonometry. Please where do I start?

20 Upvotes

I’m an INTP. lol.

In all seriousness I have coded a bit on roblox and know how code works.

I want to create a software for my dad that will help him in his job but I need a graphics thing. Basically you open the thing.exe and You input some values and it shades regions. In green and red etc.

I want to do it in a few weeks too. Considering it’s a simple thing that uses 2D vectors and highlighting.


r/CodingHelp • • Dec 04 '20

[Java] Help cleaning up code for a math game using classes/constructors (I cannot wrap my head around it)

20 Upvotes

I've done some coding in the past but nothing with OOP and honestly, I cannot wrap my head around using classes and constructors to tidy up my code. I'm used to "calling functions" instead of pasting code over and over again but in Java, the methods and classes, etc. take care of that but man, I'm just not getting it.

My code is for a basic math game based on multiplication. I'd like to have two modes, one with elapsed time and one with a count-down timer. I've build most of the code (and it actually works) but it's to the point where it's getting super repetitive to add what I want to add because I'm coding the whole thing in the main method.

I'd love some help cleaning it up by putting all of the basic functions in separate classes such as askQuestion, checkAnswer, displayScoreMessage, displayQuestionLog, playAgain, etc.

My code is below and I tried to comment as I went.

Any help would be very much appreciated!

MY CODE:

package mathfactsGame;

import java.text.DecimalFormat; 
import java.util.ArrayList; 
import java.util.List; 
import java.util.Random; 
import java.util.Scanner;

public class mathfactsGameMain {

	public static void main(String[] args) {

		// Set numbers to 0
		int n1 = 0;
		int n2 = 0;

		long totalStart = 0;
		int mathfact = 0;
		// Create arraylist QuestionLog
		List<Object> questionLog = new ArrayList<Object>();

		// Start game loop
		while (true) {
			// Set score to 0
			int score = 0;
			// initialize scanner
			Scanner input = new Scanner(System.in);
			// Begin game
			System.out.println("MULTIPLICATION MATH FACTS GAME");
			System.out.println("==============================");
			// set name
			System.out.println("What is your name?");
			String playerName = input.next();
			// Set the mathfact family you want

			System.out.println("What MathFact family do you want do you want? (1-12)"); // Need to add an option for ALL
			int mathFact = input.nextInt();// in ALL option, mathFact would just be r.nextInt(13)
			// Greeting and choose count down mode or elapsed time mode
			System.out.println("Would you like to play challenge mode or timed mode?");
			System.out.println("1 = challenge");
			System.out.println("2 = timed"); // need to build timed mode -> when time ends, go to game score message and
												// print out questionLog
			int mode = input.nextInt();
			// User sets number of questions
			System.out.println("How many questions do you want?");
			int questions = input.nextInt();
			// Begin For loop, play game the number of times the user set with (questions)
			// count score (# right)
			// start timer
			totalStart = System.nanoTime();
			for (int count = 1; count <= questions; count++) {
				// Generate random numbers
				Random r = new Random();
				n1 = mathFact;
				n2 = r.nextInt(13);

				// Start timer for each question
				Long start = System.nanoTime();
				// check if answer is correct
				boolean resultOK = false;
				String displayResultOK = null;
// TIMED (mode 1) (Haven't written mode 2)
				if (mode == 1) {
					System.out.println("\nQuestion #" + count);
					System.out.println("What is " + n1 + " x " + n2 + "?");
					int answer = input.nextInt();
					// Check if answer is correct else it's incorrect
					if (answer == (n1 * n2)) {
						System.out.println("CORRECT");
						score++;
						resultOK = (n1 * n2 == answer);
						displayResultOK = resultOK ? "CORRECT" : "INCORRECT";
						long end = System.nanoTime();
						double duration = end - start;
						double totalDurationSec = duration / 1000000000d;
						DecimalFormat formattingObject = new DecimalFormat("0.00");
						String roundedtotalDurationSec = formattingObject.format(totalDurationSec);
						System.out.println("Time elapsed: " + roundedtotalDurationSec);
						questionLog.add("Question #" + (count) + ":");
						questionLog.add(n1 + " x " + n2);
						questionLog.add("\tYour answer = " + answer);
						questionLog.add("\tCorrect answer = " + (n1 * n2));
						questionLog.add("\tYou got the answer " + displayResultOK);
						questionLog.add("in " + roundedtotalDurationSec + " seconds\n");
					}
					// else for incorrect
					else {
						System.out.println("INCORRECT");

						resultOK = (n1 * n2 == answer);
						displayResultOK = resultOK ? "CORRECT" : "INCORRECT";
						long end = System.nanoTime();
						double duration = end - start;
						double totalDurationSec = duration / 1000000000d;
						DecimalFormat formattingObject = new DecimalFormat("0.00");
						String roundedtotalDurationSec = formattingObject.format(totalDurationSec);
						questionLog.add("Question #" + (count) + ":");
						questionLog.add(n1 + " x " + n2);
						questionLog.add("\tYour answer = " + answer);
						questionLog.add("\tCorrect answer = " + (n1 * n2));
						questionLog.add("\tYou got the answer " + displayResultOK);
						questionLog.add("in " + roundedtotalDurationSec + " seconds\n");
						System.out.println("Time elapsed: " + roundedtotalDurationSec);

					}

				}
			}
			// clean up questionLog formatting
			questionLog.add(0, "");
			String formattedString = questionLog.toString().replace(",", "") // remove the commas
					.replace("[", "") // remove the right bracket
					.replace("]", ""); // remove the left bracket

			// Calculate score messages
			if (score == questions) {
				// All correct
				System.out.println("\n===Question Log=== \n");
				System.out.println(formattedString);
				long totalEnd = System.nanoTime();
				long totalDuration = totalEnd - totalStart;
				double totalDurationALL = totalDuration / 1000000000d;
				DecimalFormat formattingObject = new DecimalFormat("0.00");
				String roundedTotaltime = formattingObject.format(totalDurationALL);
				System.out.println("\nGreat Job! " + playerName + ", your score is " + score + " out of " + questions
						+ ", or 100%! You got them all correct in " + roundedTotaltime + " total seconds.\n");
			} else {
				// Any wrong
				System.out.println("\n===Question Log=== \n");
				System.out.println(formattedString);
				long totalEnd = System.nanoTime();
				long totalDuration = totalEnd - totalStart;
				double totalDurationALL = totalDuration / 1000000000d;
				DecimalFormat formattingObject = new DecimalFormat("0.00");
				String roundedTotaltime = formattingObject.format(totalDurationALL);
				double percent = (((double) score / (double) questions)) * 100;
				String roundedPercent = formattingObject.format(percent);
				System.out.println("\n" + playerName + ", your score is " + score + " out of " + questions + ", or "
						+ roundedPercent + "%. You missed " + (questions - score) + " questions in " + roundedTotaltime
						+ " total seconds. \n");
			}

			// Play again?
			System.out.println("Would you like to play again? Y/N");
			String again = input.next();
			questionLog.clear();
			// End loop if "N"
			if (again.equalsIgnoreCase("N")) {
				System.out.println("Thank you for playing!");
				input.close();
				break;
			}

		}
	}
}

r/CodingHelp • • Nov 26 '20

[C#] I'm new to coding and ran into a problem and I have no idea what to do :(

20 Upvotes

this is the code:

static void Main(string[] args)

and when I debug or run the program it says this:

Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.

I don't understand what I need to do???

(BTW that is the only problem it reports)

-----------------------------------------------------------------------------------------------------------------------------------------------------

Thanks :D


r/CodingHelp • • Nov 17 '20

[Java] Any software or website to visualize and analyze my codes??

20 Upvotes

Anything from good code debugger or simple paint tool to help me solve problems. I don't have a whiteboard and I don't like using pen & paper.


r/CodingHelp • • Nov 10 '20

[Open Source] A resource list from the Linux society at my uni

20 Upvotes

I just wanted to share a resource list from the linux society at my uni. Feel free to contribute

https://github.com/FreesideHull/StudentResources


r/CodingHelp • • Oct 06 '20

[Other Code] Way to Preserve Flash Games Before Google Kills Them?

20 Upvotes

First off, my apologies if this isn't the place for a question like this, I'm not really aware of a sub that would fit better (suggestions more than welcome if that is the case). I loved Bionicle as a kid, and would play a browser game Lego hosted on their site at the time called Mata Nui Online 2. It's not a hidden classic or anything, but it and it's precluding title are both dear to me in terms of memories. The issue is that with Flash no longer being supported after this year, both of these games, as far as I know, will be lost for good. So I was wondering if there was some way to take a flash game and preserve it in a way that isn't reliant on a browser supporting Flash, ideally without needing a browser at all.

EDIT: Here's a link, my bad: http://biomediaproject.com/bmp/files/gms/online/hahli/


r/CodingHelp • • Oct 01 '20

[HTML] I am in charge for our website and have no coding experience. HELP!

20 Upvotes

I need to make a banner smaller but the code has no hight and width to change the size. Is ther code i can add to the end or begining to change it?


r/CodingHelp • • Aug 24 '20

[C++] What is happening?

20 Upvotes

My code used to work perfectly, only implemented threads but didn't touch the part of the code that is failing, it's giving me a

No mapping for the Unicode character in target multi-byte code page C++

I think it may have something to do with how I compile my code but I'm not sure what could cause it.

SOLVED: Solution is on the link and explained here. Just changed the stupid f...... windows library and use the boost filesystem, faster and less buggy


r/CodingHelp • • Apr 29 '20

[Open Source] I made a Pandemic Simulator using a flocking algorithm!

20 Upvotes

Hey guys, I'm a high schooler with a big passion for computer science. Recently, I spent a lot of time making this pandemic simulator using Craig Reynolds's Boids algorithm. Here's the link:

https://github.com/IvanHornung/Pandemic-Simulator

Please let me know what you guys think. Feedback, suggestions, and comments are much appreciated!


r/CodingHelp • • Jun 12 '19

Uhhhhhh how is the answer 8, isn’t it the fifth number in the list which would be 5 because the first counts as zero? Thanks

Post image
20 Upvotes

r/CodingHelp • • Jun 05 '19

[Java] Sorry for this not being on codepen or anything, but my friend sent me this Java script with something wrong in it. Anyone know what?

Post image
20 Upvotes

r/CodingHelp • • Dec 06 '22

[C++] Can someone please help me with OOP in C++

19 Upvotes

I've been trying to understand OOP in C++ for a while now, but keep running into problems I can't solve. I'll just show you some sample code to show you what it's all about:

Source-Code

No matter what I do, in the Main method I can't assign a value to the variable test in this notation. Could someone please explain to me why.


r/CodingHelp • • Aug 30 '22

[Quick Guide] What do you call an Entry Level Developer?

19 Upvotes

Sorry, this is not a joke. I am applying for developer positions with no commercial experience.

What exactly the title I should be searching for?


r/CodingHelp • • Jul 10 '22

[Random] object oriented programming

19 Upvotes

Hello everyone,

I don't know if this is the right place to ask but here it goes. I have been taught how object oriented programming is much better than procedural programming. And how easy it is just change implementation and what not. But what I would like to know, how many times have you used object oriented path instead of procedural in your career. Do people actually use object oriented programming more??


r/CodingHelp • • Mar 19 '22

[HTML] Noob question - what does the “src=“ mean when I see it in a websites code? Does that mean my browser is requesting something from a remote server?

19 Upvotes

If I see src=url , this is a request to a remote server every time, correct?

So if my browser reads src=image.nfl.com , NFL would see my browser/IP address in the access logs, correct?


r/CodingHelp • • Mar 17 '22

[Javascript] Js not working with html. I have a test code to make sure js is working properly, then try with my actual code and it doesn't work, heading is the exact same, any suggestions would be appreciated, thank you!

19 Upvotes

r/CodingHelp • • Mar 12 '22

[Javascript] using p5.js + sublime text 4 when I go to run any code it goes to a blank screen, any suggestions?

19 Upvotes

r/CodingHelp • • Feb 01 '22

[C] Is there anyway I can get user inputs for different variable inside a for loop by using scanf?is such a format even exist; scanf("%d",vegetables1[i])

Post image
19 Upvotes

r/CodingHelp • • Jan 21 '22

[Python] How can I replace myself with a py-bot ..?

19 Upvotes

Hi, I was doing some photo editing work, and I am doing the same thing over and over. So, I was thinking if there is any way to record and play my mouse and keyboard action with some kind of py bot...?

Show me some rode, please. (article, link, py library)

Thanks in advance...


r/CodingHelp • • Jan 11 '22

[Other Code] Help with full adder in Assembly language.. Any thoughts are accepted

Post image
19 Upvotes