Tagged Questions
11
votes
4answers
621 views
“Two-pass algorithm” implementation in Java
I'm rather new to Java and to algorithms in general. I implemented the so called Two-pass algorithm, and want to know if there are improvements to my way of implementing it. What it does is it takes a ...
3
votes
3answers
843 views
11
votes
3answers
456 views
Bank card validation module
I hope that someone could review a module I wrote for bank card validation. I included a class that tests some of the methods, this is purely to show the methods work, rather than unit testing. I ...
7
votes
2answers
87 views
Output in one window
Can anyone give me feedback please? I used what I have learnt so far, mainly methods, loops and arrays. I would like you view based on these topics, however, comments on how to improve are welcome.
...
3
votes
1answer
86 views
Parsing version number from a Java source file
I'm extracting the version number from a file like this one. It works, but I find it clumsy and longer than probably needed.
I'd also appreciate some sanity checks as long as they don't make the code ...
5
votes
3answers
181 views
Manipulating Common Fractions
I'm a beginner Java student currently learning from Absolute Java 5th edition. I think I understand the content well but I am never sure of my style. This code is for a question after the second ...
5
votes
1answer
67 views
Downloading a page in Android
I tried to create a class which downloads the html source from a link and saves it. I'm a newbie to all this Android stuff, even new to Java, but this is what I have so far.
It seems to work at ...
5
votes
3answers
259 views
Multiple background tasks
This is taken from my post at Stack Overflow here.
I need your help to review my code for improvement and best practice.
...
6
votes
1answer
106 views
Simple stop watch
I'd like my code to be solid and good. That's why I want someone a little more experienced to give me some feedback so I can improve. Here is the code for a simple stop watch that I created. I feel ...
10
votes
2answers
395 views
Finding average of eight immediate neighbors of a matrix
I have this basic Java code to find average of eight immediate neighbors of a matrix.
Is there any way to simplify or merge any part of it, or can I refactor it?
I'm a beginner in Java programming ...
10
votes
2answers
102 views
“Event Binding” in Java employing Lambda
As I am relativistically new to programming and lack any sort of formal experience in the matter, I was wondering if any of you with a bit more knowledge in the subject would be willing to tell me if ...
14
votes
6answers
1k views
7
votes
3answers
225 views
Alarm clock with “ringing” functionality
I have a question regarding a program that is to run an alarm clock and display the time (HH:MM AM/PM) and also trigger the alarm and display "ringing" at 12:00 AM.
I am a beginner in Java and I am a ...
1
vote
1answer
55 views
Kings Cup drinking game
I'm working on a card game in Java that simulates the drinking game Kings Cup for a school project. I'm having trouble putting the pieces together, and was wondering if someone could tell me what I ...
10
votes
3answers
156 views
Very basic calculator using methods
I have made a basic calculator using methods. This is my first attempt at using methods and would like to see if I can improve on this as there is a lot of repeated code.
...
14
votes
3answers
593 views
Planetary Nomenclature
I'm new when it comes to Java and programming in general, but I feel I have a decent grasp on a lot of the fundamentals.
I've created this "random planet generator" that is virtually useless aside ...
11
votes
5answers
2k views
Logical Sudoku Solver in Java
I've been working on a Sudoku solver as an introduction to the Java programming language. I know there's a bunch of ways to program a Sudoku solver, including a brute force/recursive approach and a ...
14
votes
4answers
1k views
First attempt at a Blackjack game
I am not happy with this code as I am sure there are better ways to do what I'm trying to achieve. I'm a beginner and I've used what I know to date to complete this.
...
8
votes
2answers
100 views
Quadratic Expression Calculator 2
After taking some great advice on this question, I'm hoping for some more feedback on my quadratic expression calculator.
This is my code as stands:
...
12
votes
7answers
637 views
Quadratic expression calculator
I'm hoping to get some feedback on how to improve and optimise a program I wrote which takes three values as input (via the terminal) and uses them in the quadratic formula.
I'm aware this is mostly ...
15
votes
5answers
561 views
Collatz Sequence
I'm a beginner and I only know limited amounts such as if, while, do while. So I'm here to ...
6
votes
2answers
168 views
Pass an array of numbers into a method that's overloaded
I'm doing my homework and it says to write a test program that prompts the user to enter ten double values, invokes this method, and displays the average value.
I was able to get this program working ...
7
votes
5answers
961 views
And the little one said “Roll over”
Below is some code I have written today to test out some bits I have learnt. It isn't much nor is it spectacular. Please critique and let me know what I could/should have done differently or anything ...
6
votes
2answers
203 views
Android Thread and Runnable
This is my code for running a background thread. I believe it is very poor in naming and code structure.
...
4
votes
2answers
69 views
Modularizing an else if statement
Is there any way to take this chunk of an else if and make it its own method? I would need the values of valid and throwLine() to be done in the method containing this if else statement, but I'm ...
6
votes
2answers
293 views
Cleaning up Reverse Polish Notation evaluator
I was wondering if anyone had some general clean up advice on my code. I believe that more helper functions would be my case but I could be wrong. 30 lines maximum per method is my rule. I can't seem ...
14
votes
4answers
734 views
Modelling a Call Center
This is the requirement I have (from the book: Cracking the Coding Interview)
Imagine you have a call center with three levels of employees: fresher, technical lead (TL), and product manager (PM). ...
5
votes
3answers
530 views
Increase performance of removing character from String
I wrote this function as part of interview practice. This method removes a character from a given string.
I was wondering how I could make this code more efficient when it comes to runtime/space. I ...
2
votes
2answers
111 views
Reusing objects using a Generic Object Pool
After reading a lot of documents, I wrote this object pooling code. Can anyone help me to
improve this code.?
I am lagging in validating the object, confirming whether I can reuse it or not?
If ...
7
votes
1answer
114 views
Model simulation using Java annotations
A couple of days ago I posted my code that models systems made up of moving parts. I got several great tips and ideas and here is my latest version. My actions are now methods annotated with @Action ...
9
votes
2answers
719 views
Math expression solver
Recently I've stumbled upon an interesting challenge for me.
You should develop C application, that solves math expressions. Operations such as (+,-,*,/) should be supported, as well as (cos, sin, ...
11
votes
3answers
1k views
Find longest sequence horizontally, vertically or diagonally in Connect Four game
I'm new to programming and also to Java and working on problems in Intro to Java by Robert Sedgewick. Here is my question:
Connect Four: Given an N-by-N grid with each cell either occupied by
...
6
votes
3answers
157 views
Factory for classes unknown at compile time
I have a class called Machine. It contains a list of parts and a list of actions. The list of parts will contain instances of the ...
6
votes
2answers
4k views
Read an input text file and store the tokens in 2 different arrays
I am very new to Java so please ignore if there are obvious mistakes. If my question seems redundant then please guide me towards the correct link. However, I have surfed enough in order to find the ...
7
votes
1answer
559 views
Java Calculator
I tried to make a calculator in Java and have added some stuff. I'm a beginner and have learned yesterday how to make buttons.
...
14
votes
5answers
3k views
5
votes
2answers
2k views
Finding the most common character in a string
I have started to try and work out the TopCoder problems. The "StringDup" problem asks us to:
Create a class called StringDup. Given a string made up of ONLY letters and
digits, determine which ...
11
votes
3answers
5k views
Simple Java calculator
I am a beginner in Java programming. Here is my simple calculator. I hope you could scan through my coding and let me know if there is any error in my coding or how I could simplify the code.
...
7
votes
2answers
133 views
Matching program in Java
I am new to Java and wrote one small program. It works fine, but it looks like it doesn't meet OOP concepts. Could someone look and give me advice so that I can fine tune?
...
7
votes
1answer
174 views
Game Of Life optimization in Java
I've been working on a version of Conway's Game of Life for about a week now. It has loads of features like drawing onto the screen and saving/loading images. The problem is that ever since I added ...
7
votes
2answers
278 views
Alternative algorithm to solve maxMirror problem of Codingbat
I request you to provide insightful suggestions to improve the following code as well as an alternative algorithm to solve it.
Problem Specification:
We'll say that a "mirror" section in an array is ...
4
votes
4answers
90 views
Music list program
I need a little help with improving my first Java program. I have programmed for about a month, so my code is quite messy. The program is a "Musiclist" program, with which you can add songs, edit ...
22
votes
6answers
6k views
“Guess a number” game
I began the journey to be a self-taught programmer about a month ago and my biggest fear about teaching myself is developing bad habits and not realizing it.
I'm looking for criticism on this "Guess ...
7
votes
1answer
159 views
Suggestions needed for alternative methods of solving sudoku
I am new to programming as well as this site. I am learning Java as my first programming language. I have written a bit of code (of course after struggling a lot). I would love to read expert reviews ...
5
votes
3answers
1k views
Inputting and sorting three integers
The problem to the question is:
Write a program that takes 3 integers as an input from the user using input dialog messages and sorts the three numbers.
I just want to know: is there any major ...
4
votes
2answers
83 views
How to make a program that lies one-third of the time?
I am supposed to take this code (that I made):
...
6
votes
2answers
84 views
Visualization of the Traveling Salesmen Problem
I am working on a little project to visualize the algorithm for the Traveling Salesman Problem. I have cities, which are movable objects painted with AWT and Swing. Also I can make a connection ...
5
votes
4answers
415 views
Battle game simulation seems to have too much code
Can someone tell me if my code is too long for what it does? Please be nice — I just started trying to learn a couple days ago.
...
1
vote
2answers
130 views
Shortening code to create a JFrame
I'm new to Java and have just started making JFrames. I wrote a program for a game project I'm working on and would like help on where I can improve. I'm not new to ...
6
votes
2answers
171 views
Cleaning up calculator program
I recently started learning and programming Java based on a series of beginner videos created by a Youtuber (TheNewBoston), who had a tutorial on a calculator. So based on everything else I've ...