homework

How to make a color picker from image?

Hi, How can I make a color picker, which gets a value of images pixel and refreshes any time I click on different pixel, shows it? It must be done in java. ...

Parser problem - Else-If and a Function Declaration

A quick, fun question - What is the difference between a function declaration in C/C++ and an else-if statement block from a purely parsing standpoint? void function_name(arguments) { [statement-block] } else if(arguments) { [statement-block] } Looking for the best solution! =) Edit: Thanks for the insight guys. I was actually ...

String length without using length() method in java

How can i find the string length without using the length() method in java ...

DFS function, can you guys tell me what is the wrong with this code?

can you guys tell me what is the wrong with this code? it is not working with 1 2 1 3 1 4 2 5 2 6 2 7 2 8 3 8 3 9 4 10 1 -> 4 -> 10 and stop DFS function void Is_Connected(graphType* g, int v){ //function to define the graph is connected or not int i=0; g_node* w; top = NULL; g -> visited[v] = TRUE; push(v); print...

Programming-General: What are the 5 stages in which a source code is transformed to a executable file?

I receive this question in a test: What are the 5 stages in which a source code is transformed to a executable file? ...

C# Recursion SumOfOnlyNeg Elements

Hello, A array gets filled up with random elements (negative and positive). Now i want to calculate the sum of ONLY the postive elements. Iterative there is no problem, but in the recursion version i can only get the sum of both negative and postive. How can i "check" in the recursive version that it only sums up the Postive element...

Spatial domain to frequency domain

I know about Fourier Transforms, but I don't know how to apply it here, and I think that is over the top. I gave my ideas of the responses, but I really don't know what I'm looking for... Supposed that you form a low-pass spatial filter h(x,y) that averages all the eight immediate neighbors of a pixel (x,y) but excludes itself. a. Fin...

Problem with sending out variable to serial port using api JAVA

We are developing a java program for school. But we are experiencing problems with sending out a variable created by 3 sliders. The idea is that we have 3 sliders. One slider for every color. Red green and blue. The variable has to have a value between 0 and 255. Everytime the value of the slider changes is has to send a variable for th...

What happens to class members when malloc is used instead of new?

I'm studying for a final exam and I stumbled upon a curious question that was part of the exam our teacher gave last year to some poor souls. The question goes something like this: Is the following program correct, or not? If it is, write down what the program outputs. If it's not, write down why. The program: #include<iostream.h>...

How to create extensible dynamic array in Java without using pre-made classes?

Yeah, it's a homework question, so givemetehkodezplsthx! :) Anyway, here's what I need to do: I need to have a class which will have among its attributes array of objects of another class. The proper way to do this in my opinion would be to use something like LinkedList, Vector or similar. Unfortunately, last time I did that, I got fire...

Replacing multiple characters in C#

How would i write a program, using the replace method, that rotates the vowels in a word? meaning the letter 'a' would be 'e', 'e' would be 'i', 'i' would be 'o', 'o' would be 'u', and finally 'u' would be 'a'. For example, the word "instructor" would be "onstractur". I hope someone can answer my problem. ...

Creating ActionEvent object for CustomButton in Java

For a hw assignment, we were supposed to create a custom button to get familiar with swing and responding to events. We were also to make this button an event source which confuses me. I have an ArrayList to keep track of listeners that would register to listen to my CustomButton. What I am getting confused on is how to notify the lis...

Good use of recursion in chess programming?

Hi, As part of a homework assignment, I have to program a simple chess game in Java. I was thinking of taking the opportunity to experiment with recursion, and I was wondering if there's an obvious candidate in chess for recursive code? Thank you, JDelage ...

Strange errors in Clips

Hello, I want to make a program in Clips which generates all the partitions of a number. First of all I start with the number like his basic partition: (1 1 1 1 1) if it is number 5, etc. (deftemplate partition (multislot p) ) (deffacts facts (p 1 1 1 1 1) ) (defrule adds (p $?a ?b ?c $?d) (not (p $?a (+ ?b ?c) $?d)) (not (...

Quicksort 3 way partition

I want to implement the quicksort 3 way partition. Here is the code: public class quick3 { public static void quicksort3(int a[],int l,int r) { int k; int v = a[r]; if (r<=l) return; int i = l; int j = r; int p = l-1; int q = r; for (;;) { w...

File IO, Handling CRLF

Hi, i am writing a program that takes a file and splits it up into multiple small files of a user specified size, then join the multiple small files back again. 1) the code must work for c, c++ 2) i am compiling with multiple compilers. 3) I am reading and writing to the files by using the functions fread() and fwrite() 4) fread() an...

how to form an array of numbers , taken input from a file in C

The program should be able to make an array of numbers from a text file which reads like this The data is given as this 123 2132 1100909 3213 89890 my code for it is char a; char d[100]; char array[100]; a=fgetc(fp) // where fp is a file pointer if (a=='') { d[count1]='/0'; strcpy(&array[count],d); count=count+1; memset(d,'\0',100)...

How can I add two arbitrarily large numbers using only stack allocated memory in C++?

How can I write a program that adds two arbitrarily large numbers using stack allocated memory in C++? I am not allowed to use dynamic allocations on the heap such as malloc or new. ...

Creating Java Dialogs

What would be the easiest way for creating a dialog: - in one window I'm giving data for envelope addressing, also set font type from list of sizes - when clicked OK, in the same window or in next window I get preview of how the envelope would look like with the given names, and used selected font size It should look similarly to this :...

Java Programming Help

hi, im a bit confused on this and i dont know how to solve this question that i have been asked, id be grateful if you could assist me on this question, maybe try to tell me what needs to be done, and how. the question is: Write a method called countChars which takes an InputStream as a parameter, reads the stream and returns the numbe...