homework

how to find words within a range in a TreeSet<String> using regular expressions (java)

I am iterating though a TreeSet and printing it out: while (it.hasNext()) { System.out.println(it.next()); } output: after explorers giant hoping internet into . . . virtual world However, I would like to only print out those strings who's first character is within the range m-z. I have been playing around with java.util.regex, ...

string separation in C

I've a string like "1234567890". Now I need to store/print out this with the following format, 123-456-7890 What is the best method to implement this in C? Thanks for comments/answers. ...

"Multiple inheritance" (generalisation relationship) in data models

For some school groupwork, I'm making a Generic Pizza Delivery Everything Management System, and got stumped on a problem during data modelling that I can't figure out without using at least several layers of ugly. The restaurant keeps stock of ingredients and beverages/snacks/etc. (I'll refer to these as "drinks"). Drinks have a sellin...

convert an exression to a string representation?

Consider the following Haskell code: module Expr where -- Variables are named by strings, assumed to be identifiers: type Variable = String -- Representation of expressions: data Expr = Const Integer | Var Variable | Plus Expr Expr | Minus Expr Expr | Mult Expr Expr d...

How to verify if a rule exists in a prolog file clause database

I'm working on a college assignment where I must verify if a certain clause (as a fact or as a rule) exists in the current clause database. The idea is to use a rule whose head is verify(+name, +arguments). This rule should be true if in the database exists another rule whose head is name(arguments) Any help would be greatly appreciat...

Vectors in Java, how to return multiple vectors in an object...

I'm working on a java program, and I have several vectors defined and filled (from a file) inside a method. I need to return the contents of all the vectors from the method. I have heard you can put them all in one object to return them. Is that possible, and if so, how? If not, do you have any possible solutions for me? Thanks in a...

Primitive recursion

how will i define the function 'simplify' using primitive recursion? simplify :: Expr -> Expr ... simplify Simplify an expression using basic arithmetic, e.g. simplify (Plus (Var "x") (Const 0)) = Var "x" ...

Symbolic simplification in Haskell (using recursion?)

How can I give a general rule that includes all the expressions below? E.g one expression, another one for sub and one for mult. I need to use recursion but i got confused... simplify :: Expr->Expr simplify (Mult (Const 0)(Var"x")) = Const 0 simplify (Mult (Var "x") (Const 0)) = Const 0 simplify (Plus (Const 0) (Var "x")) = Var "x"...

How do I simplify the below expressions using primitive recursion ?

The simplifications I have in mind are 0*e = e*0 = 0 1*e = e*1 = 0+e = e+0 = e-0 = e and simplifying constant subexpressions, e.g. Plus (Const 1) (Const 2) would become Const 3. I would not expect variables (or variables and constants) to be concatenated: Var "st" is a distinct variable from Var "s". For example simplify(Plus (Var "...

DFS Tree question

In an undirected graph, can two nodes at an identical distance n from the root of a DFS tree be neighbors in the original graph? I'm thinking no, but I'm not sure (because of back edges) ...

write a quick fortran program

How can I write a quick program in fortran. I need to ask 3 questions with an option to exit after each question. ...

How to do drop-down box like "More action" in gmail

I see the "More Action" drop-down box in gmail inbox page. It has levels and some disabled item in the list. How to do that in HTML+CSS? Thank you ...

How can I sort an array of strings?

I have a list of input words separated by comma. I want to sort these words by alphabetical and length. How can I do this without using the built-in sorting functions? ...

Using double, return string

In the application I'm writing, one of the methods allows for the numbers the user entered to be turned into letters. For example, the user will be entering grades (as doubles) and the program will decide (when the criteria is met) to return the letter associated with the number. Initially, I had it written like this: public void GetGra...

Shell Scripting?

Hi, I am not sure what I am to use for this task, but I am guessing it is shell scripting. But I myself am not familiar with what shell scripting is, so I'm not sure how to do it or if it is possible. If you can give me links or advice, that would be great. What I want to do is: Create a file, simple text file EX: param1 (RANDOMVA...

Why can't I call a public method in another class?

I've got these two classes interacting and I'm trying to call four different classes from class one for use in class two. The methods are public and they do return values but for some reason there is not a connection being made. The error I get when I try is: "An object reference is required for the nonstatic field, method, or property ...

SQL Division using 'not exists' in mysql

I have the following table: 'committee' table commname profname ======================== commA bill commA jack commA piper commB bill commB piper and I am trying to find the professors who are in every committee that 'piper' is in (answer should be piper and bill): I have the following SQL division query but it'...

C# foreach within a foreach loop.

I don't have too much experience with C# so if someone could point me in the right direction I would greatly appreciate it. I have a foreach loop that references a variable of an object. I wish to make another foreach loop inside the main one that compares (or performs actions on) the current variable to the rest of the variables in th...

How do you link two arrays?

I'm in a basic programming class, and everything is done in pseudo code. My question is this: How do you link two arrays? I have a single-dimensional array that lists students names, and I have a two-dimensional array that lists the top eight scores of each student...this is all fine and dandy, but now I need to sort the arrays by th...

Write XML file (using XStream) to filesystem in Java

I need to be able to serialize a string and then have it save in a .txt or .xml file. I've never used the implementation to read/write files, just remember I am a relative beginner. Also, I need to know how to deserialize the string to be printed out in terminal as a normal string. ...