Questions tagged [homework]

Questions requesting help with school homework. This tag lets potential answerers know that they should GUIDE the student in solving the problem, rather than showing a complete solution. CAUTION: Before posting, consider that classmates may be tempted to reuse code from your post. (Read the tag wiki.)

Filter by
Sorted by
Tagged with
5
votes
1answer
3k views

How is my quarterly sales statistics program?

Am I making good use of a 2-D array? Is this code inefficient? I am supposed to receive input from 6 departments for 4 quarterly periods in Java. My assignment asks: Quarterly Sales Statistics ...
6
votes
4answers
11k views

Palindrome program with reverse method

I wrote a program for a college assignment, and I'd like to receive some pointers on making my code a little more efficient. The program should ask the end user to enter an integer. Use the <...
6
votes
4answers
386 views

Organizing semaphores into a pyramid

My homework was to organize semaphores into a pyramid. The task was accomplished, but I ended up with this long ugly conditional and was wondering if anyone can see a better way/algorithm to ...
5
votes
5answers
52k views

Book program with arrayList

I have this Book program that contains 2 classes: Book and Library. I have the Book class done, but need some help on the ...
6
votes
3answers
12k views

Singly linked-list with smart pointers

A few things: I tried to do it with smart pointers because I wanted to learn about them. I'm not sure I made the right choice of type, however (and started to regret it half-way through). This is ...
1
vote
3answers
3k views

Intro to Java - determine valid unique numbers

This is an assignment for an intro to Java course. It works with the test case given, but I would like to know if there is anything / a lot of things that should be different or could be better. ...
3
votes
3answers
3k views

Approximating sines and cosines using up to five terms of the Taylor series

I have one programming question: The sine and cosine of \$x\$ can be computed as follows: \$\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!} - \dots\$ ...
2
votes
1answer
500 views

Guessing a random number between a range of numbers

What is the general design pattern for declaring variables in a class? I have a homework assignment to create a simple Java program which asks the user for a range of two variables. The program then ...
3
votes
2answers
957 views

Print largest two integers from a stream

I'm writing a program for my intro to comp sci course where I'm supposed to prompt the user to enter a stream of integers, and then return the largest two. We were given the hint to use a scanner and ...
2
votes
3answers
6k views

Beginner Java Counter code

My professor wants me to do this: Write a number of interchangeable counters using the Counter interface below: ...
4
votes
2answers
2k views

Searching through a contact list for given criteria

I have been staring at this code for awhile now and I am thinking there is a way to optimize it (namely the if-else statement ...
2
votes
2answers
774 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 ...
2
votes
2answers
12k 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!) ...
2
votes
3answers
2k views

Extracting numbers from a string into an ArrayList

This first stores a string as input, loops through it to extract all of the numbers into an ArrayList, then prints all of these numbers along with their sum and ...
4
votes
1answer
419 views

Grade report builder

I am starting out with Java programming and get limited feedback from my professor. Following is an assignment that I handed in, and just re-factored. I wanted to see if people with Java experience ...
4
votes
2answers
2k views

Battleship type game in Java

I made the code, and it works, but it uses many if conditions and it looks ugly. I would really appreciate it if someone could give me a hand by pointing me in the ...
2
votes
1answer
202 views

High School Java Class: Pong Project External Reviewer

It would be a huge help if you could tell me ways to make my code run smoother and if I could add more code to my program to make my program more unique. Panelball class: ...
5
votes
1answer
4k views

Creating and testing a Fraction class

The exercise is as follows: Create a class called Fraction that can be used to represent the ratio of two integers. Include appropriate constructors, properties, and methods. If the denominator ...
7
votes
1answer
4k views

Simple Pig Latin Translator

The goal of my assignment is simple: 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 and placing that ...
7
votes
4answers
1k views

Printing all binary strings of length n

I have completed my homework with directions as follows: Declare and implement a class named Binary. This class will have a method named printB(int n) that prints all binary strings of length n. ...
1
vote
3answers
256 views

Primes Tester for speed performance

I was given a homework assignment in Java to create classes that find Prime number and etc (you will see in code better). ...
11
votes
2answers
23k views

Hash table implementation in Java

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 ...
5
votes
4answers
940 views

Simple static integer stack

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: ...
5
votes
1answer
24k views

Java multithreaded file server and client - emulate TCP over UDP

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 ...
4
votes
2answers
3k views

Print character + the ASCII value, 10 pairs per line

My exercise was: Write a program that reads input as a stream of characters until encountering EOF. Have the program print each input character and its ASCII decimal value. Note that characters ...
10
votes
1answer
49k views

Java multi-thread file server and client

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 and there is no need ...
2
votes
2answers
233 views

Where to start refactoring? [closed]

I am currently programming, but I messed up my code. What is the best way to clean this? buttonUitvoeren_Click_1: ...
0
votes
1answer
1k views

C for Nios-2 IRQ handling

Related: Nios 2 interrupt handler ...
17
votes
7answers
135k 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
945 views

RPN Evaluator that writes the results to a text file

For homework, I had to write an RPN Evaluator and write the results to a text file. I've done all that, but it feels weird, like the writing to my results text file. It also doesn't feel efficient. ...
3
votes
2answers
456 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 ...
3
votes
2answers
485 views

addMatrix() method

Can anyone review my addMatrix() method to see if I am following the instructions correctly? These are the instructions: This is a ...
11
votes
4answers
3k views

Turning an array of words into a random license plate

This is an assignment question from school: Write a method called licencePlate that takes an array of objectionable words and returns a random licence plate that ...
5
votes
3answers
1k views

Printing a 2D array

The problem presented to me: Declare a two-dimensional array of ints in main. Write a method to read in the size of each dimension, allocate memory for the array and return it (DON'T DO THIS IN ...
8
votes
3answers
9k views

Simple array-based Stack class in Java

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, my tests may not be as comprehensive as ...
4
votes
2answers
176 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 ...
11
votes
4answers
29k 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, ...
3
votes
2answers
2k 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? ...
10
votes
4answers
8k 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
3answers
821 views

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 ...
25
votes
6answers
3k 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 ...
2
votes
2answers
8k 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
1k 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. Here'...
3
votes
1answer
469 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 ...
2
votes
2answers
459 views

Displaying a certain element among inputted numbers

I prompt the user for 9 numbers, store those numbers in 9 pointers and display the element 2. It seem to work just fine, but am I forgetting something? Can I improve it but keep it simple? I'm just a ...
3
votes
2answers
259 views

Finding the cheapest one-way air flight fare

I'm doing a sort of exercise where I'm given a question, and I have to answer it by writing an SQL query using a database that I was given. This is the question: What is the cheapest fare for a ...
3
votes
2answers
295 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 ...
9
votes
1answer
17k views

Inversion count using merge sort

...
4
votes
2answers
2k views

Inventories of iPods for different countries

We were given two countries, namely Brazil and Argentina. Both had one inventory each with 100 iPods in them. The cost of an iPod in Brazil was 100/unit and in Argentina it was 50/unit. But to get ...
4
votes
2answers
310 views

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: ...

1
6 7 8
9
10