homework

Help with Java Multithreading

Alright, this is a sort of dual-purpose question. The main thing I hope to take away from this is more knowledge of multithreading. I am a complete newbie when it comes to multithreading, and this is my first actual attempt to do anything in multiple threads. The other thing I hope to take away is some help with a piece of homework that ...

Problems with Making a Highscore and Loops and Overall Issues

Hey guys , thanx for the previus help..... This time it's homework meaning they want me to make a highscore that shows playername,score (tries it took) and time. Basically it wants: To write a game in which a user is to guess a random number between 1 and 1000. The program should read a number from the keyboard, and print whether the gu...

Big-O notation Help

while (n >= 1) n /= 2; I am unable to get the Big-O notation for this ...

Java Array Manipulation

Ok so I have a function named resize, which takes a source array, and resizes to new widths and height. The method I'm using, I think, is inefficient. I heard there's a better way to do it. Anyway, the code below works when scale is an int. However, there's a second function called half, where it uses resize to shrink an image in half. S...

How do i change my merge algorithm to accept different arguments in c++?

The original code i wrote uses these arguments: int m = size of sorted list 1 int n = size of sorted list 2 int A[] = sorted list 1 int B[] = sorted list 2 int C[] = merged list of 1 and 2 I was asked to add this code to an existing file that uses these different arguments: IntVectorIt start1 IntVectorIt end1 IntVectorIt start2 ...

I'm having a hard time understanding java objects and classes

Example 1 /** *Program Name: Cis36L0411.java *Discussion: Class -- Data Members ONLY * Method Members ONLY */ class Cis36L0411 { public static void main( String[] args ) { DataOnly data1 = new DataOnly(); System.out.println( "DataOnly\tLIMIT\t\t" + data1.LIMIT ); System.out.print...

Quicksort (JAVA)

Lets say you have an array of size 1,000,000 with randomly generated elements and you want to use quicksort to sort the array. In order to speed up quicksort, it would make sense to stop recursing when the array gets small enough, and use insertion sort instead. In such an implementation, the base case for Quicksort is some value base > ...

how to write a java program that detects inputted capitial letters?

i need to write a eclipse java program that asks a user to input a word and then reads the word and then displays if the word contains any capitial letters. ...

moving of disc in tower of hanoi

Please explain to me the recursion process step by step using F7. I just can't correlate the return with flow of control. #include<stdio.h> #include<conio.h> void t_of_h(char, char, char, int); void main() { int n; clrscr(); printf("Enter no of DISC in Tower of Hanoi : "); scanf("%d",&n); printf("\nTower of Hano...

Why is this program overloading () operator ?

Currently I am studying Standard Template Library (STL). In this program I am storing some long values in Associative Container and then sorting them according to unit's place (according to the number in unit's place). Code : #include <iostream> #include <set> #include <functional> using namespace std; class UnitLess { public: ...

Building a right angled triangle with recursion.

I have this homework which required to print asterick to make draw a triangle. When drawTriangle(0); * When drawTriangle(1); * ** When drawTriangle(2); * ** * * **** when drawTriangle(3); * ** * * **** * * ** ** * * * * ******** when drawTriangle(4); * **...

Finding the smallest integer that can not be represented as an IEEE-754 32 bit float

Possible Duplicate: Which is the first integer that an IEEE 754 float is incapable of representing exactly? Firstly, this IS a homework question, just to clear this up immediately. I'm not looking for a spoon fed solution of course, just maybe a little pointer to the right direction. So, my task is to find the smallest positi...

randomizing text file read in java

I am trying to read a text file in java, basically a set of questions. With 4 choices and 1 answer. The structure looks like this: question option a option b option c option d answer I have no trouble reading it that way: public class rar{ public static String[] q=new String[50]; public static String[] a=n...

Representing a signed 8-bit integer?

IF F6 base hex is a signed 8-bit integer, how much does it represent in decimal? ...

How can I represent math variables in c#?

Hi, I need to represent these mathematical equations in code and to solve them: 2x = 3y 3y = 4z 2x + 3y + 4z = 1 Please advise. Thanks, Oz ...

Java: Using charAt in a loop and determining the number of spaces in the input.

This is the assignment: Write a program that determines the number of spaces in an input line. Read in the line into a string. Next use the charAt( ) method in a loop to access the characters one by one. The code I have thus far: import javax.swing.*; import java.lang.Character; public class Assignme...

How do I write an addElement method for a custom Model class extending AbstractTableModel?

For a hw assignment, I need to setup a JTable in Swing, and populate the table's contents via a custom model class that extends the AbstractTableModel. My questions regarding this overly complicated process are many fold, but I'll try and keep it simple. My first step is to get data into the model right? When I was using a JList (I coul...

Uninitialized int vs Integer

Hi all, I was just studying up on my Java in preparation for an exam and I ran into a sort of problem with uninitialized int/Integer values. class A { int x; Integer y; static int z; static Integer z2; public A(){} } Lets say I initialize an object of Class A. A a = new A(); I've tried th...

Demonstrating package names collision in java

I got this question as an assignment: Packages/Naming We have created lot of packages and defined classes and interfaces in them. We have also discussed the point we have to remember while naming them. In this assignment we will see how important naming is. Please change the package names in your previous assignment such th...

I'm trying to put a switch statement with another switch statement

I wrote a switch statement that I have to put with another but I'm not sure how to. This is the one I'm trying to put with the other switch statement. import java.util.Scanner; public class Main public static void main(String[] args) { String input; char name; Scanner keyboard = new Scanner(System.in); ...