homework

TypeError: can't multiply sequence by non-int of type 'float' - Need help.

salesAmount = raw_input (["Insert sale amount here \n"]) ['Insert sale amount here \n']20.99 >>> salesTax = 0.08 >>> totalAmount = salesAmount * salesTax Traceback (most recent call last): File "<pyshell#57>", line 1, in <module> totalAmount = salesAmount * salesTax TypeError: can't multiply sequence by non-int of type 'float' I...

Help with K&R exercise: Multidimensional array into pointer array.

Exercise (5-9): Rewrite the routines day_of_year with pointers instead of indexing. static char daytab[2][13] = { {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; /* day_of_year: set day of year from month and day */ int day_of_year(int year, int month, int day) { ...

how to generate xml file dynamically using PHP?

HI.......... i have to generate a xml file dynamically at runtime........So plz help me. <?xml version="1.0" encoding="UTF-8"?> 2. <xml> 3. <track> 4. <path>song1.mp3</path> 5. <title>Track 1 - Track Title</title> 6. </track> 7. <track> 8. <path>song2.mp3</path> 9. <...

Breadth-First search in Java

Hi I am having to run a breadth-first search in Java for an assignment. I have a 5x5 grid of tiles (24 in total - 1 tile is left 'blank'). The point of the search is to rearrange the tiles by moving the 'blank' up, down, left or right to eventually rearrange the tiles into the correct order. To do this search, I have created an Arrayli...

How to write the sequence 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 in JAVA ?

I'm currently beginning to program with Java. I tried to code the sequence in the title as an output in Java, but I'm stuck! I'm experimenting with the for function, any help is welcomed ;) ...

How to design a movie database?

Hi Guys, I'm trying to get my head round this mind boggling stuff they call Database Design without much success, so I'll try to illustrate my problem with an example. I am using MySQL and here is my question: Say I want to create a database to hold my DVD collection. I have the following information that I want to include: Film Tit...

suggestions for ERD

I am trying to prepare an ERD. There are three entities population, GeographicRegion, and inidividuals. looking for some suggestions for attributes for them? Some I have: Individuals: race, gender, name Population: size, race GeographicRegions: region, temp any other suggestions? ...

C# vs Java Garbage Collector

Hi There Does anyone know the major differences between the Java and C# garbage collectors? A web search has not revealed much, and it was a question that came up in a test. Thanks, Mike ...

Make a negative number positive in Java

Hi, I'm sure this is a very simple question! I have a Java method in which I'm summing a set of numbers. However, I want any negatives numbers to be treated as positives. So (1)+(2)+(1)+(-1) should equal 5. I'm sure there is very easy way of doing this - I just don't know how!! Any tips would be much appreciated. ...

How to write the Fibonacci Sequence in Python

Updated: EDIT! I have coded the program wrongly. Instead of returning the Fibonacci numbers between a range (ie. startNumber 1, endNumber 20 should = only those numbers between 1 & 20), I have written for the program to display all Fibonacci numbers between a range (ie. startNumber 1, endNumber 20 displays = First 20 Fibonacci numbers). ...

What is the output of this pseudocode?

procedure DoSomething(a_1, ... a_n) p = a_1 for i = 2 to n temp = p for j = 1 to a_i p = p * temp DoSomething(10,2,2,2) We are getting mixed results. One of us got 10^7, the other 10^27. I Think I found my error... I keep substituting 10 for p every time, instead of the new value for temp. EDIT: here's my work: {10, 2, 2, ...

How to determine if a linked list has a cycle using only two memory locations.

Does anyone know of an algorithm to find if a linked list loops on itself using only two variables to traverse the list. Say you have a linked list of objects, it doesn't matter what type of object. I have a pointer to the head of the linked list in one variable and I am only given one other variable to traverse the list with. So my...

How do I get past this variable initialization problem?

How do I get past this variable initialization problem? If I only could figure out how to only initialize them only once... * Main.cpp : main project file. /************************** Begin Header **************************/ #include "stdafx.h" //Required by Visual C ++ #include <string> //Required to use strings #include <iostr...

C++ compilation errors

It seems this method for creating a Global Object is not working! Here is my code: #include "stdafx.h" #include <iostream> using namespace System; using namespace std; #pragma hdrstop class Tester; void input(); class Tester { static int number = 5; public: Tester(){}; ~Tester(){}; void setNumber(int newN...

Java Problem: Returning a string entered as reverse text

Hi, I'm trying to make a method that returns a string of words in opposite order. IE/ "The rain in Spain falls mostly on the" would return: "the on mostly falls Spain in rain The" for this i am not supposed to use any built in Java classes just basic java So far i have: lastSpace = stringIn.length(); for (int i = strin...

Best algorithm for avoiding loss of precision?

A recent homework assignment I have received asks us to take expressions which could create a loss of precision when performed in the computer, and alter them so that this loss is avoided. Unfortunately, the directions for doing this haven't been made very clear. From watching various examples being performed, I know that there are cert...

Can someone please help? Basic programming class.

Write a program that sums the sequence of integers as well as the smallest in the sequence. Assume that the first integer read with scanf specifies the number of values remaining to be entered. For example the sequence entered: Input: 5 100 350 400 550 678 Output: The sum of the sequence of integers is: 2078 ...

The while language

For my theory of computing languages class, we got a homework assignment to implement a piece of code in a language that only has while statements for flow control (no if statements). This is mainly to prove that you can write a Turing-complete language with only a while loop. For those of you who can understand language grammars, here...

Numeric TextBox

Hi, Im new to programming and I dont know very much about but I'm making a calculator, and i want to use a textbox that only acepts numbers and decimals, and when the user paste text from the clipboard the textbox deletes any literal characters, like the MS calc. Please take the time to explain each part so I can learn or write it and ...

Java game questions

I am developing a simple multiplayer 2d game of pacman in java for my assignment at university and I want to be able to draw stuff onto this window as well as pick up keyboard input. What would be the best way to do this? Currently for the GUI I have http://pastebin.com/m1009789e Which works fine on the windows machine that I am developi...