homework

Java BucketSort

I'm sure you probably get this a lot from CompSci students, I tried searching but mine looked a lot different from anything else I could find. Anyway, here is my class, it is supposed to sort an array of integers (then in the future be modified to sort objects, but ints will do for now). My goal is to make an arrayList which is basicall...

Loop won't end despite the use of a sentinel value.

This is an example straight out of my text book, and I can't get it to end the loop. import java.util.Scanner; public class Play { System.out.println("Enter scores for all students."); System.out.println("Enter a negative number after"); System.out.println("you have entered all the scores."); Scanner keyboard = new Sc...

C++ Use secant method to solve function

Hi, I have a school problem but I do not understand what it actually asks. Any of you have an idea what it's really asking for? I don't need code, I just need to understand it. This is the problem: Construct a computer program that uses the Secant method to solve the problem: f(x)  =  (1+x) cos( sin(x)3 ) -  1.4   =  0 Starting with th...

How to display Ford owners that don't own Ferarris in SQL

Hi, I'm learning SQL and I've written a query that returns all owners of Fords. How do I amend the query so that it doesn't return anyone who owns a Ford and a Ferarri? SELECT DISTINCT Owns.Pid FROM (Person INNER JOIN Owns ON Person.Pid= Owns.Pid) INNER JOIN Car ON Owns.Cid=Car.Cid WHERE Car.Manufacturer = 'Ford' Added: I tried th...

sorting the linked list

I am trying to make a function that sorts the linked list,which sorts the list by names. struct student { char name[50]; int roll_no; struct student *ptr_next; }*ptr_this,*ptr_first;/*ptr first points to first pointer */ void SortRecord(void) { struct student *out,*in,*temp; for(out=ptr_first;out!=(struct student*)NULL;out=out...

what is the correct way to define a struct inside a class?

Hey! I have a class called SparseMatrix which contain a private vector of type Cell. Cell is a structure that should hold x,y coords and a double value. In addition, I would like that a different class called RegMatix will be able to declare a vector of type Cell also. this is the struct: struct Cell { Cell(int row,int col, Numbe...

filter Hashes in Ruby

q = {"It", "was", "the", "best", "of", "times", "it", "was", "the", "worst", "of", "times"} write an expression to return wasworsttimes without using any character or string literals. Can someone help me figure out how to do this? ...

C linked list search function

Edit: Stupid error. I found it. Thanks for the help though. Sorry i can't keep my code up ...

How to exit the loop with the number 0? but now i have other problems

package hw3; public class Main { public static void main(String[] args) { final int NumberOfElements = 1000; int[] num = new int[NumberOfElements]; int var = 0; //create input java.util.Scanner input = new java.util.Scanner(System.in); for (int i = 0; i < NumberOfElements; i++) { ...

functions in lisp

Hi.... I have this question for a homework assignment.... I'm having difficulty with cost-of-applying-operator and estimated-distance-from-goal Basically its the 2 jug problem one 4ltr jug and one 3 ltr jug and we need to get 2 ltrs in one... we're provided with the a-star code and i've done the jug-problem.lisp just not sure how to w...

java - Can someone explain to me what is going on? there's a lot of things going on in which I haven't been taught yet.

public class Main { public static void main(String[] args) { int[] x = {1, 2, 3}; increase(x); Reverse rev = new Reverse(); rev.reverse(x); System.out.println(x[0] + " " + x[1] + " " + x[2]); } //Increase every element in the array by 1 //For example: array : 0, 1, 2 will become 1, 2, 3 public s...

check for vowel in a given string

i would like to make a program which checks the character which is input is vovel or not but not able to input char with jTextField1 i tried Character.parseChar but nothing is happening. ...

Haskell - Currying? Need further explanation.

So something like addList :: [int] -> int addList = foldl1 (+) Why does this work? The Currying part. Why no variable? Thanks ...

How to transfer a file in a client/server Java application.

Hello everyone! I am currently working on a homework assignment and I am thoroughly stuck. I am on the last question and I just can not figure out how to go about accomplishing the last task. Below is the tasks I had to complete: The client should save the file in the "client" subdirectory of the home directory. Test your program....

c syntax problem w/some changes now

Right now I am only trying to get my getline() function to work. I have the code from the book and it seems to be identical, but I cant get it to compile. This is homework but this part should be just copying from the book. #include <stdio.h> #include <stdlib.h> #include <math.h> //error list #define ENDOFFILE = -1; #define TOOMANYN...

Heading the right way on c matrix code?

My instructor said the way to start this is to use the getline() function from out book, then get the numbers from the line, then have those numbers in matrix form, I do not understand why I would use getline? //eventually this code should take in a square matrix and from 2x2 to 6x6 //the plan is to get it to read in a line, then get t...

Haskell - Create Set (unique sorted list) - no recursion, no nub

is it Possible to create a function that will create a set with an input of a list. I just can't think of any way without using recursion. I can use high order functions like fold, filter, map, zip. I just can't have recursion in my function. Obviously i can't use nub. I've been banging my head trying to figure out how to get rid of...

Linked list problem

Hello, I got some problem with the linked list I've written. I dunno if it's either my insert function that the problem, or if it's my traverse function that's not correct. I hope for some input. A side note, I'm initalising the list in main now since I don't know if my initNode function is correct. #include <iostream> using namespace ...

Scheme String Help

I am trying to write a function that evaluates to the number of distinct characters in the input string str. So for example (distinct-char "eeeiicczz") would return 4. I need some help with my code. This is what I have. (define string-contains (lambda (str char) (if (equal? str "") #f (if (char=? (string-ref str 0...

Matlab: graphing function basics

Consider the function f with branched definition f(x)= x − 2x^2/3 for 0 ≤ x ≤ 1; x − 2 − cos(πx) for 1 < x ≤ 3. Write an anonymous function for f and Plot the graph of the function over the interval to allow you to estimate its zeros. Use these estimates in the FZERO command to find the positive zeros (that is, the posi...