homework

Implementation of file "save" like Notepad

Hi Experts, I want to create a text editor (using java/swing) like notepad. For this I need the implementation of saving file. mean if the user clicks on "save" first time then the dialog should appear for taking file-name, file-extension. But if he clicks again on same "save" button then the file should save without appearing the "save...

Random Characters in pseudocode

My assignment is to create in pseudocode a module that accepts a 200 element array of alpha characters. How do I write the code to choose the 200 characters at random and put them in an array? My full assignment is: Create a module in pseudocode which accepts a 200 element array of characters, determines the number of occurre...

c++ m bits permutations of a number

Hi, I am searching for a function that get as an input a number x (assuming 15), number of bits d (4) and number of permutations m (2). The output of the function will be all the numbers that are m bit's permutations from the given number x at a d length bits. For the given numbers, (x = 15, d = 4 and m = 2) we get 6=\binom{4}{2}differ...

nested looping in python

in a string suppose 12345 , i want to take nested loops , so that i would be able to iterate through the string in this following way :- 1, 2, 3, 4, 5 would be taken as integers 12, 3, 4,5 as integers 1, 23, 4, 5 as integers 1, 2, 34, 5 as integers ... And so on. I know what's the logic but being a noob in Python, I'm not able to f...

python raw_input def input problem

I am only going to post the portion where the problem is at, the program has no error (all the codes are valid except for this raw_input problem) I tested with search_function(1) and etc and it worked. But if I do this while loop, it doesn't print anything. Example output: Enter a number to print specific table, or STOP to quit:...

Why does it throw a NullPointerException?

Hi, I have a database class which has this method and it will be called in the other bean class (when I choose an image)(imagin I work with name and family,... not with id) my method: public static void insertImageToBirthTable(String name, String family, String fatherName, String motherName, String dateOfBirth, String placeOfBirth, Str...

problem with while loop / java

im doing a program which has two different questions, ohm and ampere to be exact. i know how to make this work but the problem is that in the end one more question should pop up asking " do u want to make a new calculation?" this question should work like if i press "Y" the program should continue from the beginning and if i press "N" t...

Function in Scheme that checks whether the length of a list is even

Hi I have edited the code for function in scheme that checks whether the length of a list is even. (define even-length? (lambda (l) (cond ((null? l)#f) ((equal? (remainder (length(l)) 2) 0) #t) (else #f)))) Is it corrrect? ...

java Semaphore north south que

There are two queues of children waiting to use a roundabout in a playground – one is facing it from the north, one from the south. Children may only enter the roundabout from the front of either queue and may only enter if there is a space available (only one child may use each segment at a time). Once on the roundabout they use it for ...

Implementation of a simple algorithm (to calculate probability)

EDIT: I've got it, thanks for all the help everyone! + Cleaned up post a little bit. Also, this article was very helpful: http://www.codinghorror.com/blog/archives/001204.html?r=1183 Hi all, I've been asked (as part of homework) to design a Java program that does the following: Basically there are 3 cards: Black coloured on bot...

CR character in gets() function

The user types a string, possibly separated by tabs, spaces and "enters" (CRs). I need to receive all of it; the problem is that gets() function stops the scan when the user presses the "Enter" key. Is there another way to do it? I cannot use any other function except for scanf and gets. ...

Homework: Need guidance on creating an OO non-graphical/text adventure game

Okay... I'll try to describe it. It's a text adventure game where you have items you pick up and encounter monsters in rooms (they can be hard-coded in). All my pickups are going to do damage, and the player and the monsters have hitpoints, a name and damage (so the pickups just add to the player's damage when you use them). We have to...

What does the '0' in line 41 mean?

#include <iostream> #include <cctype> // isdigit using namespace std; // Global buffer const int LINE_LENGTH = 128; char line[LINE_LENGTH]; int lineIndex; void getLine () { // Get a line of characters. // Install a newline character as sentinel. cin.getline (line, LINE_LENGTH); line[cin.gcount () - 1] = '\n'; lineIndex = 0; } ...

[2D Array in C] How to write a program that use 2D array to generate a matrix?

Suppose user enter a integer "3", the matrix should 3 X 3 and some random numbers in it. For example: 8 0 2 6 3 4 5 7 1 I need to use 2D array to do it. But I have no idea about how to finish it. Here is my code, what should I do now? #include "stdafx.h" #include "stdlib.h" #include "time.h" int _tmain(int argc, _TCHAR* argv[])...

Hello, Can anybody suggest me any game in C or C++ for my second semester project in post graduation?

I'm doing post graduation in computer science. In the second semester I wish to do a game in C or C++ so that I can apply my knowledge in these languages and this will add to my existing knowledge about these languages. Please suggest to me a good topic and a brief description about it. I have one of my classmates with me to do the proje...

Brute force with NULLs

Hi, Does anyone know how to write a brute force program where if, say, the lenght is 4, in the beginning, the string would be a\0\0\0, b\0\0\0,..., ab\0\0 and so on, ie keeping its NULLs. My question is for a password cracking homework. Thanks ...

Reversing Part of a List in Prolog

My goal for this Prolog function is as follows: Given two lists, x and y, return true if y can be formed from x by reversing a contiguous part of list x. For example, if the input is x = [1, 3, 2, 4], y = [1, 2, 3, 4], the result should be "true" because we can reverse the second and third elements of x to get y. I really have no ide...

Adding Combo-box dynamically

Howdy folks.. I'm trying to design a table in HTML which can add a row when I click "add row" button & the same for deleting an added row if i intend to delete it. I have written a javascript for adding checkbox and text. But I want even combo-boxes in it and I m stuck in the middle. Could you guys just figure it out and let me know ho...

Information Gain and Entropy

I recently read this question regarding information gain and entropy. I think I have a semi-decent grasp on the main idea, but I'm curious as what to do with situations such as follows: If we have a bag of 7 coins, 1 of which is heavier than the others, and 1 of which is lighter than the others, and we know the heavier coin + the lighte...

calculating expression without using semicolon

Given the expression by input like 68+32 we have to evaluate without using a semicolon in our program. If it will be something inside the if or for loop? Reference : https://www.spoj.pl/problems/EXPR2/ ...