homework

Explain JAVA code

I need some help to explain the meaning from line 5 to line 9. Thanks String words = "Rain Rain go away"; String mutation1, mutation2, mutation3, mutation4; mutation1 = words.toUpperCase(); System.out.println ("** " + mutation1 + " Nursery Rhyme **"); mutation1 = words.concat ("\nCome again another day"); mutation2 = "Johnny Johnny wa...

Calculate car filled up times

Here is the question: The driving distance between Perth and Adelaide is 1996 miles. On the average, the fuel consumption of a 2.0 litre 4 cylinder car is 8 litres per 100 kilometres. The fuel tank capacity of such a car is 60 litres. Design and implement a JAVA program that prompts for the fuel consumptio...

Problem with numbers

I am given a number N, and i must add some numbers from the array V so that they wil be equal. V is consisting of numbers that are all powers of 3: N = 17 S = 0 V = 1 3 9 27 81 .. I should add numbers from V to N and S in order to make them equal. The solution to the example above is : 17 + 1 + 9 = 27, 27, 1 and 9 are taken fr...

NullPointerException, Collections not storing data?

Hi there, I posted this question earlier but not with the code in its entirety. The coe below also calls to other classes Background and Hydro which I have included at the bottom. I have a Nullpointerexception at the line indicate by asterisks. Which would suggest to me that the Collections are not storing data properly. Although when I...

How can I store an inventory using Perl hashes?

For an assignment in college, we have to make a script in Perl that allows us to manage an inventory for an e-store. (The example given was Amazon). Users can make orders in a fully text-based environment and the inventory must be updated when an order is completed. Every item in the inventory has 3 to 4 attributes: a product code, a ti...

Python - retrieving info from a syslog file

I have been asked to write a program using python for an assignment. I have been given a syslog file and I have to find things out about it How do I find out how many attempts were made to login to the root account? Any advice would be highly appreciated as I am very new to python and completely lost! ...

Implementations of Mobile IP on linux

Are there any standard implementations of Mobile IP for Linux? If I want to support mobile IP for a network, what all needs to be done? If I have to write code from scratch, is it likely that a kernel module will suffice or I would have to make changes to the kernel code. I just need a bit of headstart to know where to begin. ...

Python - filter by date

how do i count how many logins were done per day on a system using the log file n python? ...

C# Function that generates strings according to input

Hi, I need a C# function that takes 2 strings as an input and return an array of all possible combinations of strings. private string[] FunctionName (string string1, string string2) { //code } The strings input will be in the following format: String1 eg -> basement String2 eg -> **a*f**a Now what I need is all combinations of ...

Declaring a function inside a function?

I have came across the following code, and being a C beginner, I came here for your help. This function is from a c implmentation of a queue. Bool queuePut(Queue *q, char c) { void beep(); if (queueFull(q)) { beep(); return false; } //do stuff return true; } So, I am getting a strange erro...

using java Calendar

I have a simple task. There are two classes : Ticket and Date. Ticket contains event, event place and event date which is a Date object. I also need to provide a move() method for Date object, so I used Calendar and Calendar's add(). Everything looks fine apart of the output. I constantly get the same date for all Event objects. The code...

I need help on my C++ assignment using Microsoft Visual C++

Ok, so I don't want you to do my homework for me, but I'm a little lost with this final assignment and need all the help I can get. Learning about programming is tough enough, but doing it online is next to impossible for me... Now, to get to the program, I am going to paste what I have so far. This includes mostly //comments and what I ...

Cartesian product in Scheme

I've been trying to do a function that returns the Cartesian Product of n sets,in Dr Scheme,the sets are given as a list of lists,I've been stuck at this all day,I would like a few guidelines as where to start. ----LATER EDIT ----- Here is the solution I came up with,I'm sure that it's not by far the most efficent or neat but I'm only ...

getline(cin, variable) not wanting to work properly in c++?

Here's my program so far: int main() { char choice = 'D'; string inputString; cout << "Please input a string." << endl; getline(cin, inputString); LetterCount letterCount(inputString); while(choice != 'E') { cout << "Please choose from the following: " << endl << "A) Count the number o...

Validating an integer or String without try-catch

Ok, I'm lost. I am required to figure out how to validate an integer, but for some stupid reason, I can't use the Try-Catch method. I know this is the easiest way and so all the solutions on the internet are using it. I'm writing in Java. The deal is this, I need someone to put in an numerical ID and String name. If either one of the...

C++ How do I properly use getline for ifstream members.

Ok so I have a problem with getline. I have a file that contains a couple strings. I created it by myself and I have each string on a seperate line. Ex. textfile.txt Line 1 Line 2 Line 3 Line 4 //Little snip of code ifstream inFile("textfile.txt"); getline(inFile, string1); When I debug the program and ask it...

delete[] an array of objects

Hello I have allocated and array of Objects Objects *array = new Objects[N]; How should I delete this array? Just delete[] array; or with iterating over the array's elements? for(int i=0;i<N;i++) delete array[i]; delete[]; Thanks UPDATE: I changed loop body as delete &array[i]; to force the code to compile. ...

Casting array of pointers to objects

If B is subclass of A. And I have in main(): B** b = new B*[10]; ... // some algorithm that does b[i] = new B(..); So I have an array of pointers to objects B. Then I have a function: void f(A** foo); If in main, I do: f(b); I get a warning, but obviously if I do: f((A**)b);, I don't. The (A**) its a bit nasty. I was wondering i...

Java - String Pool

What is meant by String Pool ? What is difference between the following declarations : String s="hello"; String s=new String("hello"); Is there any difference between the Storing of this two strings by JVM ? ...

How can I write to the same file in different subroutines in Perl?

I'm having some problems writing data into a file using Perl. sub startNewOrder{ my $name = makeUniqueFileName(); open (ORDER, ">$name.txt") or die "can't open file: $!\n"; format ORDER_TOP = PRODUCT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<CODE<<<<<<<<AANTAL<<<<EENHEIDSPRIJS<<<<<<TOTAAL<<<<<<< . format ORDER = @<<...