homework

What have i done wrong? (python help)

The question i'm working on asks me to "write an expression whose value is the concatenation of the three str values associated with name1 , name2 , and name3" , separated by commas." "So if name1 , name2 , and name3 , were (respectively) "Neville", "Dean", and "Seamus", your expression's value would be "Neville,Dean,Seamus". " T...

Java question: trying to create and draw a random number of objects

Hello all, I'm a Java novice taking a beginning programming class and I'm trying to finish my homework assignment (due tomorrow!) and I've been banging my head against the wall trying to figure out what I'm doing wrong. Here's the basic assignment: create a Building class that takes parameters for x and y location - this I have don...

Please help me understand?

The question i'm working on asks "Given the variables name1 and name2 , write a fragment of code that assigns the larger of their associated values to first" ('first' in bold letters) (NOTE: "larger" here means alphabetically larger, not "longer". Thus, "mouse" is larger than "elephant" because "mouse" comes later in the dictionary ...

Logical error in Function template.

My professor has given me this assignment. Implement a generic function called Max, which takes 3 arguments of generic type and returns maximum out of these 3. Implement a specialized function for char* types. Here's my code : #include <iostream> #include <string> using namespace std; template<typename T> T Max(T first,T ...

Swap Integer variables without using any assignment

Hi, all! Could someone please help me to solve such a task. I need to swap variable values without using any assignment signs. I tried to do it with a while loop but I coudn't store counter value anywhere. Thank you all in advance. ...

Integer Byte Swapping in C++

I'm working on a homework assignment for my C++ class. The question I am working on reads as follows: Write a function that takes an unsigned short int (2 bytes) and swaps the bytes. For example, if the x = 258 ( 00000001 00000010 ) after the swap, x will be 513 ( 00000010 00000001 ). Here is my code so far: #include <iostream> u...

bit swapping with char type in C

the data type is char, and the pattern is follow: source byte: [0][1][2][3][4][5][6][7] destination: [6][7][4][5][2][3][0][1] for example, if I pass a char, 29 to this function, it will do the swapping and return a char type value, which is 116. How can I do the swapping? thank you. ======================== Just wondering if I can...

DB schema for a booking system of fitness class

I need a schema for fitness class. The booking system needs to store max-number of students it can take, number of students who booked to join the class, students ids, datetime etc. A student table needs to store classes which he/she booked. But this may not need if I store students ids in class tables. I am hoping to get some good i...

Where do I get "junk" data to help test my code?

For my C class I've written a simple statistics program -- it calculates max, min, mean, etc. Anyway, I've gotten the program successfully compiled, so all I need to do now is actually test it; the only problem is that I don't have anything to test with. In my case, I need a list of doubles -- my program needs to accept between 2 and 1,...

How to save a Control Array

Hello I have this code that allow the user to create a button array, any were in a from. I can give 2 links so you guys can fallow what its done first MSDN and second HERE this one is a Simple sample of what I am doing (on Create an account now? Click NO and then download the zip file it takes 2 seconds and I am working on version 2010 ...

python number guessing question

import sys print 'Content-Type: text/html' print '' print '<pre>' # Read the form input which is a single line guess = -1 data = sys.stdin.read() # print data if data == []: print "Welcome to Josh's number game" try: guess = int(data[data.find('=')+1:]) except: guess = -1 print 'Your guess is', guess answer = 42 if g...

How to write a function to determine the population count of a 16-bit integer using php or javascript?

How to write a function to determine the population count of a 16-bit integer using php or javascript. Population count is defined as the number of bits that are "turned on," or in others, it is the number of 1s in a binary representation of a number. For example, the binary number 0b0000 has a population count of 0 because there aren't ...

Inserting node in a double-linked list

I'm having trouble understanding the second half of connecting a new node into a double-linked list. I'm writing an add method that takes in the node which the new node is to be inserted after. My area of difficulty is understanding how to link to the next node after the previous node links have been re-directed to the new node. So, h...

Java toString Method (objects)

class Position { private double x,y; private int id; public String toString(Position a){ String words ="(" + a.x + "," +a.y + ")"; return words; So I'm getting a memory address returned here. What am I doing wrong? I want to get the actual values of x and y that were set using setters. I also have getters...

Basic Python Function and Constant Help

I'm not sure where to even start this assignment: In shopping for a new house, you must consider several factors. In this problem the initial cost of the house, the estimated annual fuel costs, and the annual tax rate are available. Write a program that determines and displays the total cost of a house after a five-year period and execu...

how to write a function to implement an integer division algorithm without using the division operator in php.

How to write a function to implement an integer division algorithm without using the division operator. Floating point values and remainders may be discarded. Error conditions may be ignored. For example: f(10, 3) is 3 f(10, 5) is 2 f(55, 5) is 11 ...

Java objects instanceof

The instructions say: Create an equals method that takes an object reference and returns true if the given object equals this object. * Hint: You'll need 'instanceof' and cast to a (Position) I have: class Position { private double x,y; private int id; public boolean instanceOf(Object a) { boolean isInstance; ...

How to bubble sort through a text file in Java

How do I do a bubble sort in java, The text file looks like this: aaa 2 bbb 3 ccc 1 What I need to do is to loop through it and display the highest score to the lowest. When I run the code below, The numbers, are already sorted. and it will display 3, 2, then 1. But the name isn't in sync with the corresponding score, it will onl...

accurate running time of each line and total running time

Show the accurate running time of each line and total running time for the following function: int f1(int n, int A[ ], int B[ ]) { if ( (n>=5) || (n<0) ) return 0; for (int i=0; i<=n; ++i) { A[I] = 0; for (int j=0; j<i; ++j) ...

Random Access of file.

Input = Line number. Output = Replace the line at given line number by new line. example = a.txt aaaa bbbb cccc input= line number=3 replace with dddd output aaaa bbbb dddd ...