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....
5
votes
1answer
74 views
Drink machine using structs homework assignment
Here's the school assignment I did:
Problem 1. Write a program that simulates a soft drink machine.
The program should use a structure Beverage that stores the following
data:
...
1
vote
3answers
73 views
Writing numbers into a file [closed]
I'm taking my first ever CS class and I have an assignment due Friday. I just wanted someone to check my code.
Instructions:
Write a program that:
gets the name of a text file of numbers ...
7
votes
2answers
760 views
Homework to display a square and calculate tips
Here's a simple school assignment I did:
Problem 1: Write a program that asks the user for a positive integer
no greater than 15. The program should then display a square on the
screen using ...
6
votes
2answers
46 views
Reading a line ending with a newline character from a file descriptor
I'm implementing a function that behaves like getline() which reads a line from file descriptor and returns the results without ...
1
vote
4answers
149 views
Program to display array elements in the ascending order of number of factors each element has
Input:
1000 23 100 26 32
Output:
23 26 32 100 1000
Since 23 has '2' factors and 26 has '4' factors and 32 has '6' ...
5
votes
2answers
332 views
itoa base function in C
This is a function that converts an integer value to a null-terminated string using the specified base and stores the result in a char array that I must allocate (...
4
votes
2answers
72 views
Processing trip route table in C
In fact, this is a group assignment for our C programming lesson, but seeking help from others is not considered cheating.
The goal of the following code is to:
Sort the data in ...
7
votes
2answers
102 views
Formatting seconds as hours:minutes:seconds
This is basically my school homework and I want to know what to improve, and what not to do.
The homework basically is this:
You will get a input in seconds, which is supposed to be shown as H:MM:SS ...
12
votes
5answers
814 views
Validating integer or string input
I'm at uni and working on an assignment in c# that takes some user input (from they keyboard via console).
The input validation required:
numbers must be within range (range will vary depending on ...
3
votes
1answer
110 views
Finding the prime factors of a positive number
I have an assignment to write on the standard output the prime factors of a positive number displayed in ascending order and separated by '*'. My code works, but I need help reviewing it before I ...
2
votes
1answer
156 views
Find shortest paths in a matrix using Dijkstra's algorithm
The problem is as follows:
I have a matrix with impassable fields those are marked by the input. There is also a castle which reaches up the right side of the matrix. I have to find how many paths ...
3
votes
1answer
99 views
Maxflow for baseball elimination game
I have a problem similar to the baseball elimination. Given some teams, the number of wins they have and the number of games they have left between each other I have to find for which team it is still ...
-2
votes
3answers
63 views
Calculating the max difference between any 2 numbers from an array
How can I make this little program work a little faster?
The task is to calculate the max difference between any 2 numbers from an array of numbers. Target time is 1 sec, now it works in 1.1 sec.
I'...
3
votes
1answer
81 views
Java Connect Four “Four in a row” detection algorithms
I am making a connect four type game for my end of the year project in my programming class. I am about to start building off of the console based version I have made and add a GUI, but I feel sort ...
7
votes
1answer
969 views
Drawing the flag of Liberia
I am working on this assignment to draw the flag of Liberia for my essentials of computer programming class.
I finished it but had extra time to kill and noticed that a couple similar blocks of ...
3
votes
1answer
52 views
Anagram counter
Homework prompt was:
You are given two strings, a ‘parent’ string and a ‘query’ string respectively. Your task is to determine how many times the query string – or an anagram of the query string ...
1
vote
0answers
67 views
Pac-Man-ish maze game
I am a freshman in university. This Pac-Man-ish Game is my final Computer science homework. I know my code is not perfect and has so many to be improved. However, Compared to corrections of this game, ...
5
votes
1answer
73 views
A “pointless” animation program
The assignment description for this code is this:
Each time the user clicks the Circles button, randomly colored circles
flow into the display and continuously change their shapes.
Here is a ...
6
votes
1answer
51 views
Producer Consumer in C
I'm doing multithreading at university and we've been asked to implement the producer consumer problem in C.
My code compiles and produces the right result. From debugging it, it seems to be waiting ...
3
votes
2answers
90 views
Booking system for shows
Kindly accept my apologies as Java is something my mind cannot digest no matter what I do. At the moment I have an assignment and have written a piece of code and have used Constructor (I think so) ...
3
votes
2answers
62 views
TCP client and server supporting six simple commands
For a class, I was given an assignment to code a simple TCP connection between a server and a client. Once the TCP handshake is done, the client sends inquiries to the server. It's a 2 second ...
5
votes
1answer
112 views
8086/DOS assembly keyboard I=input, data loss in registers
I am working on a project for class, and it works as required by the rubric, though I am wondering if there is a slightly better way to implement a few things. I was docked a few points for an ...
1
vote
1answer
120 views
7
votes
3answers
138 views
Prolog parser written in Haskell
I am writing a very simple Prolog intepreter in Haskell. It's a class assignment and I really want to do it right.
I was able to (quite quickly) write a parser for the language. Today I borrowed a ...
3
votes
1answer
117 views
“Destroy the Asteroid” Game
I made this game for my computer science class.
Here is my professor's requirements:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when ...
2
votes
0answers
77 views
Roman numeral converter project
I have a project that is due for my Intro to Java course which requires me to translate the number range of 1 - 3999 into Roman numeral form. If the number I pick is 0 it will end my program, anything ...
1
vote
3answers
348 views
Morse code translator in C#
I'm writing a Morse code translator for homework in C#. It takes an input from the user and returns the Morse code version of their input. I understand that this code may look horrible, so how could I ...
2
votes
2answers
96 views
My spaceship is slow to explode after being hit by the asteroid
I am making a game for my computer science class. My professor's requirements are:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when the left and ...
3
votes
3answers
105 views
Mortgage calculator for homework
I needed to create a mortgage calculator for an intro to CS class. As part of the assignment, with an interest rate of 6% needs to change to 7% after 3 years hence that ...
7
votes
3answers
123 views
Creating a chess board
One of my assignments was to create a chessboard. In this assignment I could not use an array, or a form of list or what not. Below is my code for the creation of the chessboard:
...
2
votes
1answer
58 views
Sampling with weighted probabilities
In an exam question I need to output some numbers self.random_nums with a certain probability self.probabilities:
I have ...
-3
votes
2answers
44 views
Display calendar using a loop
Desired output:
Can I get an shorter version of this code? My instructor just wants me to figure it out my self.
...
2
votes
2answers
62 views
5
votes
2answers
188 views
“I'm Listening”
For this next assignment, my job was to create a GUI with a button that changes text and color when clicked, and a slider that updates a label (with a TitledBorder) ...
1
vote
2answers
194 views
Tic-Tac-Toe game in JavaScript/HTML/CSS
I need help with a question my teacher wants us to do by tomorrow. I would love for you to try to help me out with this.
The following functions must be implemented:
A function that initializes all ...
2
votes
1answer
73 views
Functional Scrabble Word Score
Homework: Write a function to score a scrabble word.
values is a global dict formatted as values = {'a': 1, 'b': 3,...}
The ...
12
votes
5answers
1k views
Enter my Matrix
Here is my next Java assignment: create a Matrix class that can add and multiply two matrices together. I was given some code as a skeleton and then fleshed it out ...
6
votes
3answers
246 views
Loading tab-separated tweet data into an array
I'm working on this school project and was wondering if there was any way of storing this information better, faster, more professionally. I'm also restricted to only using an array; don't ask me we ...
5
votes
2answers
731 views
Reverse an integer, find the absolute difference, then reverse again
For one of my university assignments, we were asked to take an unsigned int, reverse its digits, find the absolute difference between the original and reversed, ...
8
votes
2answers
323 views
Bridge, We've Got a Problemo
Now that we can move across the bridge, it's time to finally set up the problem so that it can be solved. A reminder of what the assignment is:
Welcome to the Bridge Crossing Problem. Person Pn ...
4
votes
1answer
82 views
Displaying a randomly sized array as a table
This program creates an integer array with a random size of 5-50 elements (inclusive). It then fills the array with random numbers between 0 - 100 (inclusive). The interesting part comes when I then ...
6
votes
2answers
128 views
Moving across my (sturdier?) Bridge
Building on top of the classes in this question of mine, I've made this class to support the moving of the entities for my given assignment:
Welcome to the Bridge Crossing Problem. Person Pn can ...
17
votes
7answers
3k views
Sudoku solution without the use of classes
A Sudoku puzzle is a 9 × 9 grid with some numbers between 1 and 9 in
it, that has to be filled in so that
every row,
every column, and
each of the nine 3 × 3 blocks
contain all ...
8
votes
1answer
104 views
I think my Bridge's foundation is too fragile
I've just started a new class learning Java, and since it's been a long time since I've programmed in it I thought I'd put up my first project to get back in the swing of things. Here is my first ...
3
votes
3answers
119 views
Interplanetary weight calculator
I have been using this site for a couple of years for great answers and a ton of help. I wrote this program for my class project due 1/23. I am just wondering what you would recommend me changing or ...
7
votes
3answers
1k views
Check if 2 arrays have (exactly) the same elements recursively
I've been given a homework assignment to make a function to check whether 2 given arrays with the same given size have exactly the same set of elements.
My function seems to be working but I feel ...
24
votes
6answers
3k views
To 'this' or not to 'this'?
I was given a homework and I have 2 solutions: one that uses this and other one that doesn't.
I tested both solutions on jsPerf but sometimes it says the version ...
8
votes
2answers
291 views
Scoring and grading answers against an answer key
This is for a university assignment (don't worry the code is in working order), and while I could hand it in as-is and receive full marks I feel like there is probably a more efficient and better way ...
1
vote
3answers
1k views
Removing punctuation and lowercasing a string
I am very fresh to python. As part of an assignment, I've written the following code to remove punctuation from a string and convert it to lowercase.
...
1
vote
0answers
171 views
Dice rolling swipe Android app
So I've got an Android app where if you swipe in a particular direction (UP, DOWN, RIGHT, LEFT), the dice move in that direction using TranslateAnimation. This is ...