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
7
votes
2answers
1k views

Search procedure to find inputted DWORD in MASM Array

Is there any way to make this more efficient? ...
4
votes
2answers
9k views

Using threads to find max in array

I really do not have access to anyone, outside of professors, that is highly knowledgeable about Java so I figured I would post my stuff here to further my knowledge and improve my coding. This is ...
6
votes
1answer
975 views

Finite Automaton for a Typing Game

I'm creating a game that implements a finite automaton and I don't know if I'm doing it right. Any advice? Game class ...
5
votes
1answer
518 views

Fallout-style homework game

I've been going through LPHW (learn Python the hard way) lessons and I am now at exercise No36 where I have to create a similar game. Could you please review it and point out beginner mistakes? <...
9
votes
4answers
5k views

Lexical analyzer for a programming language

I'm doing a lexical analyzer for my programming language and I don't know if I'm doing it right. Can anyone can help me with this or suggest a better way of doing it? ...
23
votes
8answers
4k views

Feedback on a programming practice problem in C

This is a programming practice that our teacher gave us, and I would appreciate if someone can look over my program and tell me if I did a good job. Basically, the context is I joined a company and ...
5
votes
1answer
1k views

Optimization for add function in queue

I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code. Using Homework Questions as reference, as this is a homework related question. ...
5
votes
3answers
2k views

Rational arithmetic calculator

My program is a fraction calculator that is supposed to calculate the basic operations (+, -, *, /) and is supposed to exit when I enter % as my sentinel value. This is what I have so far; any ...
8
votes
2answers
173 views

Inputting and displaying strings

I have written some code for one of my assignments. However, I feel that I am repeating myself slightly in a few places. I have that niggling feeling that there is a better way to do things. Here ...
5
votes
1answer
813 views

Build object from database without a discriminator column?

I currently have a basic application that has a database backing it. I originally connected to the database with Entity Framework, but my tutor has requested from me to recreate the functionality with ...
6
votes
2answers
298 views

Design feedback for automaton to draw a checkerboard pattern

I've just completed the 3rd task of the 1st assignment offered by Stanford's programming methodologies (see the full resources for it here too). I just need some helpful feedback on how my code can ...
3
votes
1answer
196 views

Hangman game background image possibly inefficient

I'm making a Hangman game and it seems that my code doesn't provide me much freedom with using layouts. I added an image to my JFrame then I added a ...
1
vote
1answer
126 views

Calculating kills and deaths in a game

I'm trying to make a program that calculates your k/d ratio (kill/death, which is used in FPS games to make people believe that it's skill), how many kills you need without dying once to reach a ...
1
vote
2answers
65 views

Which way should I use while writing this method? [closed]

I've got a homework that is about methods. So first part is Write a method that prompts the customer for the car type. There are three acceptable car types (E: Economy, M: Midsize, F: Fullsize). ...
4
votes
3answers
1k views

Sorting strings in a one dimensional array

What are the better solutions possible? I have a character array with different strings. There is a max size for the strings. In case a string is smaller than max size remaining places are filled ...
9
votes
8answers
16k views

Return a string without the first two characters

I'm new to Java and am trying to solve a scenario. Even though I've succeeded and it works, I've just wondered if there was a more practical way of doing this task. Is there a quicker or more ...
2
votes
4answers
26k views

Printing a rectangle

I have an assignment as follows: Write a program which reads from the keyboard two integers n and m, and a character c from the keyboard. This program should define and call a function: print ...
22
votes
5answers
4k views

Reading and writing data for Caesar cipher

I am struggling with commenting and variable naming. My teacher says my comments need to be more explanatory and explicit. He says my variable names are also sometimes confusing. I was just wondering ...
10
votes
2answers
2k views

Guess a random number between a selected interval

My project for my class is to create a Java-based game where the user must enter a number between 1-20 and a number between 250 and 300. The computer randomly chooses a number between those 2 numbers. ...
6
votes
3answers
264 views

Hour averaging program

I am looking for tips on improving my short program. I am using system("PAUSE") because this was for an assignment. Code: ...
1
vote
2answers
20k views

Calculating a total price by using switch statement and sentinel controlled loop

My homework is to make a program that calculates the total value of products sold. It works, but I use the if statement because it was asking for the quantity on ...
15
votes
2answers
10k views

Roman numerals to decimal

This is a program for converting Roman numerals to their decimal equivalents. There must be a better way of distinguishing between, for example, 'IV' and 'VI', than what I have currently written. <...
0
votes
1answer
107 views

Processing a string from the console

How can I make this program run faster? On enter, I have a string from the console. For example: 1 1 7 3 2 0 0 4 5 5 6 2 1 On exit, it will be ...
12
votes
2answers
27k views

Perfect Hashing Implementation

I'm building a hash table for this problem: Implement a class for storing a set of integers: ...
2
votes
2answers
1k views

In-order Predecessor BST review

I was referred here from StackOverflow, so here is what I posted over there: So, for an assignment, I have to construct a binary search tree, plus an assortment of related functions. I have them all ...
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
385 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
46k 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
391 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
954 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
5k 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
763 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
400 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
3k 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
253 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
22k 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
892 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
2k 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 ...