homework

Initialize a structure with an array in a variable

How can we initialize a structure with an array (using its variable)? This version works well: MyStruct test = {"hello", 2009}; But this version is bugged: char str[] = "hello"; MyStruct test = {str, 2009}; ...

C# File I/O Efficiency

Hi, I have done a homework assignment, here is the problem statement: Your program should work as follows: Ask the user to give you a file name. Get the file name and save it. Open the file. From the file read a temperature and a wind speed. Both values should be stored in variables declared as double. The file is a text file. Each l...

Working with lists in Prolog

First off let me state that this is part of a class exercise given as homework. But, the entire assignment is much more involved than the subject of this question. So.. I am searching through two lists given to a predication. My goal is to compare the corresponding elements in this list and determine if the first one is larger. If i...

Simple reduction (NP completeness)

hey guys I'm looking for a means to prove that the bicriteria shortest path problem is np complete. That is, given a graph with lengths and weights, I need to know if a there exists a path in the graph from s to t with total length <= L and weight <= W. I know that i must take an NP complete problem and reduce it to this one. We have at...

A Method that returns true if the Temperature objects represents a temp below freezing point (JAVA)

I'm trying to write a method named isLowerThanFreezing that returns true if the Temperature object represents a temperature below the freezing point for water (32.0 F, 0.0 C, or 273.15 K), and false otherwise. This method should include only one inequality (i.e, one comparison formed using <, <=, >, or >=), which can be accomplished by d...

Bounding ellipse

I have been given an assignement for a graphics module, one part of which is to calculate the minimum bounding ellipse of a set of arbitrary shapes. The ellipse doesn't have to be axis aligned. This is working in java (euch) using the AWT shapes, so I can use all the tools shape provides for checking containment/intersection of objects....

Why is the output this? (Java)

This is an instance method from a Rectangle class where we modify the x and y coordinates of the rectangle and its width and height public void modify(int newX, int y, int width, int h) { int x = newX; this.y = y; width = width; this.height = height; } Rectangle r3 = new Rectangle(0, 0, 10, 10); r3.modify(5, 5, 50, 50);...

Good Object Oriented Design When Deleting, C++

The code below deletes the symbol associated with the stock object just fine. Its just bad object oriented design. The way that i am searching for each stock symbol is by using a != or == test for NULL. bool hashmap::remove(char const * const symbol, stock &s, int& symbolHash, int& hashIndex, int& usedIndex) { if ( isAdded == 0 ) ...

Python Programming Help

#!/usr/bin/env python import math def primeTest(isPrime): print(' {0}=testnum'.format(testnum)) if testnum%2 == 0 and testnum != 2: #if divisible by 2 and not 2 isPrime = False print('{0} a'.format(isPrime)) print('a') else: numroot = round(math.sqrt(testnum)) i = 2 while i <= numroot: if testnum%i == 0: isPrime = False...

Why am I getting null on this code?

This is a part of my source (when I enter a button) of my JDilog form. I have made an object from the SystemManagement class which is management (I have written also some part of this class). When the user add her/his information, with the addStudent() method in SystemManagement class I add her/his information to the student's list but w...

Duplicate Elimination

hi every body i have problem with this question Duplicate Elimination Use a one-dimensional array to solve the following problem: Write an application that inputs 10 integers. As each number is read, display it only if it is not a duplicate of a number already read. Use the smallest possible array to solve this problem. Display the co...

Python - read in numric csv file, calc mean value of all entries in each row

Hi, could someone help me with a Python problem. I cant seem to find any code examples for the following scenario: Read in user specified csv file. Then for each row in file, calculate the mean & stddev for all numeric values in that row & print to screen. I know csv rows are read in a string so would need to be converted to a float pr...

Rails Custom Model Functions

I'm in a databases course and the instructor wants us to develop an e-commerce app. She said we can use any framework we like, and now that we're halfway through the semester she decided that Rails does too much and wants me to explicitly write my SQL queries. So, what I'd like to do is to write my own functions and add them to the mode...

why it returns null password???

In my Generator class ,I make a new password and also I have a SystemManagements class which imports Generator class (it is in the other package) and I have some information like name and family of user and I make an object which its type is SystemManagement but when i call getPassword() on my object it will return null!!!?????? public ...

substitute in a nested list (prolog)

/* substitute(X,Y,Xs,Ys) is true if the list Ys is the result of substituting Y for all occurrences of X in the list Xs. This is what I have so far: subs(_,_,[],[]). subs(X,Y,[X|L1],[Y|L2]):- subs(X,Y,L1,L2). subs(X,Y,[H|L1],[H|L2]):- X\=H, not(H=[_|_]), subs(X,Y,L1,L2). subs(X,Y,[H|_],[L2]):- X\=H, H=[_|_], subs(X,Y,H,L2). My code w...

2d ArrayList in Java adding data

I need little help on a homework assignment. I have to create a 10 by 10 ArrayList, not an array that would make too much sense. This is what I have and I just need a hint on how to do a for loop to add the date to the 2d ArrayList. By the way this is for putting data that are grades; going from 100 to 82. (Yes I know it is homework but ...

Format a string in C

Normally you can print the string in C like this.. printf("No record with name %s found\n", inputString); But i wanted to make a string out of it, how i can do it? I am looking for something like this.. char *str = ("No record with name %s found\n", inputString); I hope this has clear what i am looking for... ...

Selecting objects contined in an Arraylist (c#)

Im working on a project for homework where I have an Arraylist containing objects of 5 strings. I know how to select items of the array list (using an index value) but not how to access the objects strings. Any help would be great (I'm not trying to cheat but its getting frustrating that I cant't sort it out. I hope this snippets make it...

a question about a design

My teammates and I have a very challenging new project to do, and we are supposed to submit it next week. We don't have a single clue about how to do it, and really need help. We are undergraduate students, new to Information Retrieval and AI, and really need your ideas. The project is roughly: When an expert is cited in a document,...

SQL Plus - Alias type question.

I need to find the book code and book title for each book whose price is greater than the book price for every book that has the type 'HOR'. My table looks like this CREATE TABLE BOOK ( BOOK_CODE CHAR(4) CONSTRAINT BOOK_BOOK_CODE_PK PRIMARY KEY, TITLE VARCHAR2(40) CONSTRAINT BOOK_TITLE_NN NOT NULL, PUBLISHER_CODE CHAR(2) CON...