logic

What's wrong with my logic (Java syntax)

I'm trying to make a simple program that picks a random number and takes input from the user. The program should tell the user if the guess was hot (-/+ 5 units) or cold, but I never reach the else condition. Here's the section of code: public static void giveHint (int guess) { int min = guess - 5; int max = guess + 5; ...

Interesting SQL Sorting Issue

It's crunch time, deadline for my most recent contract is coming in two days and almost everything is complete and working fine (knock on wood) except for one issue. In one of my stored procedures, I'm needing to return a result set as follows. group_id name -------- -------- A101 Craig A102 Craig Z101 ...

Language independent logic question

If one has three fields in a db that they are querying an object by.... One of these fields must always be an associations id. Concerning the other two fields "only one needs to be true" What interpretation do you take or make of "only one needs to be true"? ...

How do I assign a rotating category to database entries in the order the records come in?

I have a table which gets entries from a website, and as those entries go into the database, they need to be assigned the next category on a list of categories that may be changed at any time. Because of this reason I can't do something simple like for mapping the first category of 5 to IDs 1, 6, 11, 16. I've considered reading in the ...

Advanced switch statement within while loop?

I just started C++ but have some prior knowledge to other languages (vb awhile back unfortunately), but have an odd predicament. I disliked using so many IF statements and wanted to use switch/cases as it seemed cleaner, and I wanted to get in the practice.. But.. Lets say I have the following scenario (theorietical code): while(1) { ...

Units of measurement conversion logic in C#

I am adding a feature to my program in which the user will have the ability to change their unit of measurement at any time, and have the program recalculate their input and output. If the user inputs say, 20lbs for an item, then decides he wants to work in kilograms instead, he can select an option to do so at any time, and the program...

A Question About the Expressive Power of Higher-Order Logical Reasoning Formalisms.

Hi! I do not really know if this is scientifically proven, but I've read in a book (It was a relatively modern AI book by Peter Norvig) that second-order logical programming could be more expressive than existing first-order languages. The question is: Is it statistically/symbolically proven that higher-order predicate logics exceed fi...

Basic PHP logic problem

$this->totplpremium is 2400 $this->minpremiumq is 800 So why would this ever return true?! if ($this->totplpremium < $this->minpremiumq){ The figures are definitely correct and I am definitely using the 'less than' symbol. I can't work it out. ...

A question about logic and the Curry-Howard correspondence.

Hi. Could you please explain me what is the basic connection between the fundamentals of logical programming and the phenomenon of syntactic similarity between type systems and conventional logic? ...

Algorithm: Determine shape of two sectors delineated by an arbitrary path, and then fill one.

NOTE: This is a challenging problem for anybody who likes logic problems, etc. Consider a rectangular two-dimensional grid of height H and width W. Every space on the grid has a value, either 0 1 or 2. Initially, every space on the grid is a 0, except for the spaces along each of the four edges, which are initially a 2. Then consider a...

Where do I put the logic of my MFC program?

I created an application core, in C++, that I've compiled into a static library in Visual Studio. I am now at the process of writing a GUI for it. I am using MFC to do this. I figured out how to map button presses to execute certain methods of my application core's main class (i.e. buttons to have it start and stop). The core class how...

Relational Clausal Logic question: what is a Herbrand interpretation

I'm having a hard time coming to grips with relational clausal logic, and I'm not sure if this is the place to ask but it would be help me so much with revision if anyone could provide guidance with the following questions. Let P be the program: academic(X); student(X); other_staff(X):- works_in(X, university). :-student(john). :...

Want tool to obtain linear temporal logic spec from UML 2.0 sequence diagram

i am working on checking model consistency of software. to do this i need to write linear temporal logic for UML 2.0 sequence diagram. if any body have any other tool for the same please response as soon as possible. I will be very obliged to you. i have found charmy tool have plugin for the same. Does anybody have source code for charmy...

High level process of extracting images from a container

Right, this is the problem I have a container (rar,zip) which contains images png's tiffs bmps or jpegs in an order. The file extension isnt zip or rar though but uses the same compression. I want to pull out a list of images contained within the file in the numerical order, then depending on the user decision go to the image selected....

ActiveRecord Logic Challenge - Smart Ways to Use AR Timestamp

My question is somewhat specific to my app's issue, but the answer should be instructive in terms of use cases for association logic and the record timestamp. I have an NBA pick 'em game where I want to award badges for picking x number of games in a row correctly -- 10, 20, 30. Here are the models, attributes, and associations in-play...

Logic Circuits & Shift Registers?

Hey all, Could anyone point me to a logical diagram of, or show me how to create, a Parrallel In/Serial Out shift register that uses J-K Flip flops? I've found diagrams that use D types, but no J-K's. Any help would be greatly appreciated. Thanks. ...

Inference engine to calculate matching set according to internal rules

I have a set of objects with attributes and a bunch of rules that, when applied to the set of objects, provides a subset of those objects. To make this easier to understand I'll provide a concrete example. My objects are persons and each has three attributes: country of origin, gender and age group (all attributes are discrete). I have ...

how to refactor tricky logic involving consecutive sets?

The rule at work here is that users can be awarded badges for a streak of 10, 20, and 30. But the user can't be awarded multiple badges for the same streak. I'm tracking consec wins in the user model. For example, if the user hits a 10-streak, the user is awarded a 10-streak badge. If the user is on a 20-streak, he/she receives a 20-s...

Is the answer to this question "no"?

Is the answer to this question "no"? ...

File Hierarchy system with a web application logic question: List searching

I need to search through a list of folders that could have more folders inside it, and add a new folder depending what folder is its parent.(the path is stored as a String for eg = "root/MyCom/home/") Then i fill in a field with a new folder name and add it to the final folder(eg "home/"). Below as you can see , I can navigate to the r...