Homework means the question is requesting help with school homework. This lets potential answerers know that they SHOULD guide the student in solving the problem, and SHOULD NOT simply show the complete answer.

learn more… | top users | synonyms

0
votes
0answers
21 views

Fibonacci sequence indent error [on hold]

Here is my code for the above tasks for a Fibonacci sequence. I was told that I indent incorrectly, but I still couldn't figure out why it happens. Can anyone have a look for me, please? I'm very ...
0
votes
2answers
58 views

Exceptions to control data read flow

I previously posted a Reservoir-Sampling program, which was basically a test version of this one. This is an assignment. In the code below, I use RunTimeException to control when scanner finishes ...
2
votes
2answers
155 views

Am I writing this first function correctly for the program?

Write a program to read the coefficients of a series of quadratic equations from a text file and print the associated roots, or appropriate errors if there are no real roots, to another text file. If ...
0
votes
0answers
36 views

Making a binary tree work like a doubly linked list [closed]

I have one question concerning binary trees. I want to display the values from the lowest to the biggest, without really sorting the tree, after inserting the values. I thought about making the tree ...
1
vote
2answers
83 views

Any way to allocate pointer arrays without using `new`? [closed]

Here is my code: int *A = new int[n](); // operator() initializes all elements to 0 int *B = new int[n](); int *C = new int[n](); I know, I know: I should be using std::unique_ptr if I need to use ...
2
votes
2answers
59 views

Conversion of expression from Prefix to Postfix notation (Problem with precedence) [closed]

I have been attempting to write a code that converts Prefix expressions to Postfix expressions. So far here's what I have made (note that I am new and hence it may not be efficient!) ...
3
votes
3answers
113 views

How would I decompose this method into multiple methods?

How would I decompose this java program into multiple methods? It first stores a string as input, then loops through it to extract all of the numbers into an array list. Then it prints all of these ...
3
votes
2answers
185 views

Review My battleship type game

I´m basically about to fail a homework, since took this object oriented course and profesor assigned me homework where I suppose (base on a battleship game framework) to code the commands that the ...
0
votes
0answers
111 views

Would appreciate feedback on college project

would appreciate some feedback regarding best practices on the following code which is a college project. What should go in the controller and what in the views? How to attach and remove the views to ...
3
votes
1answer
160 views

Homework assignment needs review

Will someone look over my code for an exercise I was assigned. The program runs, but my instructor is pretty tough at grading. Anything I can improve on? The exercise is as follows: Create a class ...
5
votes
1answer
250 views

Everything's done, just need to write in a different way [closed]

Hey guys, the goal of my assignment is simple, here it is: Write a program that converts a given text to "Pig Latin". Pig Latin consists of removing the first letter of each word in a sentence ...
5
votes
1answer
512 views

Review my Java hash table implementation?

For class, I was asked to write a (linear probing) hash table in Java. (I was also asked to write a linear-chaining hash table, which is why I named this one HashtableB as opposed to just Hashtable.) ...
3
votes
4answers
103 views

How to Improve Stack Class C++ Implementation

This question is about improving my C++ coding skills. I was asked to implement a simple Static Integer Stack in C++ as an assignment. I've come up with the following code: class myStaticIntStack { ...
3
votes
1answer
2k views

Java multithreaded file server and client. Emulate TCP over UDP

This is for homework. My task was similar to my last assignment but this time I had to do it with UDP instead of TCP. This basically means I had to emulate TCP over UDP. Multithreading was an ...
-2
votes
1answer
66 views

PHP: what does this code do? [closed]

can somebody please explain this code for me in simple steps. thanks in advance $text = 'we need to send products ACE66765, ACE33453, and ace72345 back to the customer.'; $regex = ...
7
votes
1answer
1k views

Java multi-thread file server and client.

This is for homework. My task was to build a multi-thread file server and a client that can upload or download a named file over sockets. It is assumed that the client will finish after its operation ...
3
votes
2answers
172 views

Where to start refactoring?

I am currently programming, but i messed up my code, what is the best way to clean my code. I really need to know this, next week i must be done with the assignment, but the teacher said that the ...
0
votes
3answers
243 views

code from my class seems sloppy and confusing, am I crazy? [closed]

This is the example code for the next project for my intro class. The assignment is to add an "edit method" to this program. Some of my concerns are why the methods are returning Integers, that ...
1
vote
1answer
106 views

Please review C for Nios-2 IRQ handling

Related: Please review assembly for Nios 2 interrupts /* * Main C program for nios2int 2012-10-31 * Assignment 6: Interrupts from * timer_1 and de2_pio_keys4 */ /* Include header file for ...
1
vote
0answers
273 views

Please review assembly for Nios 2 interrupts

This is homework for which we have prepared Nios 2 assembly and C: ######################################## # Definitions of device-addresses # and important constants. # # de2_pio_keys4 - 0x840 ...
9
votes
7answers
3k views

Finding repeating numbers in an array

I want to search through an array of n numbers and find the numbers that are repeated. So far I have this code, which does the job, but I find it to be a rather cumbersome method, but I can't seem to ...
2
votes
2answers
161 views

Optimization of exponentiation

I'm writing some crypto code, and as part of it, we have to implement modular exponentiation. I have it working, both with the right-to-left binary method and with the Montgomery formula. While ...
7
votes
4answers
353 views

Not sure how to check my solution

This is a assignment question from school: Write a method called licencePlate that takes an array of objectionable words and returns a random licence plate that does not have any of those words in it. ...
0
votes
1answer
542 views

Reverse a linked list [closed]

Problem: create a linked list and reverse the list appending with '<-'. Example, if the linked list is [1,2,3,4,5,6], so the result is 5 <- 4 <- 3 <- 2 <- 1. Here is the code class ...
5
votes
3answers
112 views

Is my code dealing with the presented problem the right way?

I finished this program to print a 2D array, I got the right output, but I'm not sure if I did what was being asked in the problem below. My code to deal with the presented problem: package ...
5
votes
3answers
594 views

A simple array-based Stack class in Java, what are my mistakes?

I have created a simple array-based Stack class with some methods like the actual Stack in Java. I am testing this for mistakes, but since I am learning Java and my tests may not be as comprehensive ...
4
votes
2answers
125 views

Ordinary Data Processing Task in Haskell: Vague Misgivings

This is an ordinary data processing task: read a list of dates and amounts (for example, deposits and withdrawals from a bank account) and report the date on which the lowest balance was recorded and ...
9
votes
4answers
3k views

Simple C++ function to determine the circumference and area of a circle

First off I would like to state that this is a homework assignment. However, I am not looking for you to complete anything for me. I code I am posting is the completed homework assignment. However, ...
0
votes
1answer
225 views

Am I doing this right? Merging 2 ordered source arrays into one destination array

My instructions were: Add a merge() method to the OrdArray class in the orderedArray.java program (Listing 2.4) so that you can merge two ordered source arrays into an ordered destination ...
3
votes
2answers
256 views

Format names to title case

So I'm writing a program to format names to title case and display them in alphabetic order. Any advice please? And how can i add more methods? public static void main (String [] args) { ...
8
votes
4answers
953 views

Payroll calculator

First I tried to fetch this program as close to pseudo code where I must follow all imported items, all method definitions, and all defined variables; anything else was my choice. After I created ...
5
votes
2answers
183 views

Understanding the use of for loops as counting loops in homework review [closed]

Newbie here, first time programmer. I have a homework assignment that I am working on. Instructions: Write an application that allows input of an integer n between 1 and 71, and (using a for or ...
4
votes
3answers
255 views

Haskell: Nearest Neighbour classification algorithm

The following code is from a university assignment of mine to write a classification algorithm (using nearest neighbour) to classify whether or not a given feature set (each feature is the frequency ...
13
votes
6answers
1k views

HashSet and TreeSet

I got some homework in which I had to take the novel War and Peace and put it into a HashSet and TreeSet respectively. I had to time it, to check differences and my question is whether my ...
1
vote
1answer
2k views

Producer-consumer in C using pthread_barrier

We're preparing for an exam at the moment, and our lecturer has given us a sample problem to work on. I have it completed, but would like to know a) If it is actually doing what it's supposed to, and ...
2
votes
3answers
175 views

C inner product function without using array subscripting

As part of a question designed to help us understand the relationship between pointers and arrays in C, I've been asked to write an inner product function that doesn't use any array subscripting. ...
3
votes
1answer
154 views

Scheme, first timer first program, simple list removal technique

I have started my hand at writing some scheme code. I am trying to get the first n primes. I plan to do so but first getting a list from 2 to m, and doing the following algorithm. Remove the first ...
1
vote
2answers
370 views

How can i Improve this program C++

int n; int *array[9]; bool isUsed[10] = {0}; for(int i = 0; i < 9; i++) { cout << "Enter Number " << (i + 1) << endl; cin >> n; if((n >= 0) && (n ...
3
votes
2answers
149 views

How to optimize and shorten this SQL query?

I'm doing a sort of exercise where I'm given a question, and I have to answer it by writing a sql query using a database that I was given. This is the question: What is the cheapest fare for a ...
4
votes
1answer
410 views

First C program is too slow

I finally got my first C program to work, and it turns out to be too slow! Any critique, especially on optimization, would be much appreciated. Thanks for wading through my code! /** * File: ...
3
votes
2answers
135 views

PHP function to compare two Roman numerals

This was for an assignment. I had to write a function to compare two roman numerals. This had to return true only if the second number was larger than the first and had to be done without converting ...
5
votes
2answers
2k views

Inversion count using merge sort

count = 0 def merge_sort(li): if len(li) < 2: return li m = len(li) / 2 return merge(merge_sort(li[:m]), merge_sort(li[m:])) def merge(l, r): global count result = [] ...
2
votes
2answers
441 views

Is there a better design I can use for this code?

I am trying to solve this problem: We were given two countries namely Brazil and Argentina. Both had one inventory each with 100 ipods in them. The cost of ipod in Brazil was 100/unit and in ...
3
votes
2answers
195 views

Homework Review - Storing three integer values

Consider an 8-bit complier, in which we have an integer of size, say 2-words i.e. 16-bits or 2 bytes. You need to store three integer values which are supposed to be as: Name Range Size ...
0
votes
4answers
219 views

Insertion vs Selection

I currently have a selection sorting algorithm, but need some help turning it into a insertion sort, I understand a insertion sort if faster? The hand array is full, and it needs to sort from lowest ...
10
votes
6answers
2k views

Just checking - does my code look good? Rock+Paper+Scissors

Doing some homework and just curious if everything I've done looks good and/or if you'd suggest I modify something to keep with "javaese" Thanks! Here's the code: import java.util.Scanner; import ...
3
votes
2answers
115 views

Can someone check if my code follows the instructions of the given assignment?

I would like someone to check if I followed the instructions of the assignment. I find the instructions a little confusing. Here is the assignment: Dynamic character arrays str and add contain ...
3
votes
3answers
467 views

JavaScript Objects- Can you confirm?

Ok, I am in a JavaScript class, and I have no desire for anyone to do my schoolwork, I have already done what I think is correct, I am just hoping someone can take a look and tell me if I am close, or ...
15
votes
9answers
2k views

Most efficient way in C++ to strip strings

If I want to strip a string completely of its whitespaces, punctuation and numbers (i.e. anything that is not A-Z, a-z), what is the most efficient way of doing it in C++? I tried this: string ...
0
votes
0answers
80 views

Python 2.7 - Abstract Programming [duplicate]

Possible Duplicate: Can I make the class more abstract? import math class Point: def __init__(self,x,y): self.x = x self.y = y def move(self,x,y): self.x += x self.y += y ...