homework

Scanner fraction Sum "Formula"

So what this problem in the book is asking me to do is to write a method with a parameter N and what it should print is 1 when I call printFractionSum(1) and when I call printFractionSum(5) it does 1+(1/2)+(1/3)+(1/4)+(1/5) public static void main(String[] args) { printfractionSums(5); } public static void printfractionSums(int ...

Puzzle question

In a certain street, there are more than fifty but less than five hundred houses in a row, numbered from 50, 51, 52 etc. consecutively. There is a house in the street, the sum of all the house numbers on the left side of which is equal to the sum of all house numbers on its right side. Find the number of this house. ...

Where's the segmentation fault being generated in this threaded code?

In this homework, two matrices should be added using a different thread for each quadrant. This is my attempt so far, it generates a seg fault that I haven't been able to identify. #include <math.h> #include <stdio.h> #include <stdlib.h> #define N 4 //matrix dimension int c[4][4]; int a[4][4]={1 ,3, 4, 5, 3, 4, 5, 6,7, 8, 9, 0, 2, 1...

Java ArrayList Comparison- TicTacToe

I am trying to make a really simple Tic-Tac-Toe game. I have stored values of "X" and "O" in a 0-8 ArrayList (3x3 square, essentially). I can do the following for each instance of a winning situation: if ((newBoard().get(0)).equals("X") && (newBoard().get(1)).equals("X") && (newBoard().get(2)).equals("X")){ System.out.println("...

mismatch in formal parameter list

\a3.cpp(75): error C2563: mismatch in formal parameter list im certain im passing the fuction checkout with 3 doubles, i dont know why im getting the error i am. Please help #include <iostream> #include <cstdlib> using namespace std; const double peanut_PRICE = 1.80; const double peanut_SHIP = 0.50; const double BOOK_PRICE = 9...

Where does printk print to?

Hello guys, Just a quick question on printk function at the kernel level, if i call this where will the message be printed to.(im using ubuntu on i386 arch with the latest kernel downlaod) cant find it anywhere, if someone could also point me in the right direction for some sort of manual for the printk function it would be great! ...

Prime test, 2-digit numbers

Hi, I want to print all prime numbers that are 2-digits long. Here is my code: for(int input = 11; input <= 99; input += 2){ for(int x = 2; x < (int)Math.sqrt(input) + 1; x++){ if(input%x != 0){ System.out.println(input); break; }else{ break; ...

Where do i get the api for the linux kernel that would let me access information within the kernel

Hello guys, i am new to linux, i am after implementing a simple system call on the linux kernel that prints to the syslog via printk, i would like to be able to extend this application , so i can details on the battery percentage of my laptop or check the speed of the hard drive in the computer, could any of you give me a hand on whe...

How Arbitrary is the Representation of a Turing Machine?

Hello all, I'm working on a related decidability/recognizable problem, and to solve it, I need clarification about the encoding/representation of a turing machine. I know a turing machine is formally defined as a 7-tuple. If I have a Turing Machine U and another Turing Machine M, is it trivial to design U to recognize some part of M (...

How can I calculate the distance between two points in Perl?

I need help with a homework assignment for my beginner computer science class. I am completely lost! I need to write a program in Perl that will calculate the distance between 2 points with three values (x,y,z) by the given formula by my professor. the program must do the following: prompt for 'c' to continue 'q' to quit prompt for th...

MATLAB Matrix Sum using Nested For

I am trying to find the sum of the following matrix in matlab [1 1 1 1; 1 2 1 2; 4 5 3 2; 1 3 2 4; 10 11 1 1; 90 9 2 1] I am trying to do so using a nested for statement yet i keep getting errors. please help Must use nested for My code: A = [1 1 1 1; 1 2 1 2; 4 5 3 2; 1 3 2 4; 10 11 1 1; 90 9 2 1]; for j=1:4, for i=1:6, sum = ...

Swing: link toggle buttons together with a button group, along with corresponding menu items

For a school project, I need to make a simple paint application that can draw lines, ovals, and rectangles. The assignment specifies that I need toolbar buttons and menu items for each type of shape. I would like to go a little above and beyond, by making the buttons JToggleButtons in the toolbar and the menu items JRadioButtonMenuItem...

Adding a "useful" syscall not normally available to a non-root user....

Hey guys, I've implemented a simple Hello World syscall with limited functionality - that simply transitions from user mode to kernel mode, prints a message that is logged with the kernel messages, and transitions back to user mode. The next step for extra credit is to add a useful (new) syscall that is not normally available to a non-...

How can I sum an array?

In C#, how do I make a static method called Sum that takes one parameter of int array type and returns the sum of its parameter's elements? And what are ways to get the sum other than return Sum()? ...

SQL database queries basic question

Relational Schema: Employee (Enum, Ename) VentingMac (Enum, Cokename, day) The attribute Enum in VentingMac relation is a foreign key referencing the relation Employee. I want to list out all the employee names (Ename), who drink more than 3 (distinct) coke on the same day (assuming they wont drink the same coke each day) ...

Java error message java.lang.StringIndexOutOfBoundsException: String index out of range: 0

here is my program import java.util.Scanner; import java.util.Random; public class Project3 { public static void main(String[] args) { int low; int high; int answer; int guess; int numGuess = 0; int x; int y; char repeat; // this will hold y or n String in...

How can I return the odd numbers of a list, using only recursion in Python?

I do not want to use while or for loops, just want to use recursion to return the odd numbers in a given list. Thanks! ...

Brute force sudoku solver algorithm in Java problem

Everything seems to work fine in the algorithm besides the solve method. When it executes the program using a solvable Sudoku board, it says that it cannot be solved. I've tried everything I can think of in the solve method. I've tried debugging and it fails after the first row is tested. Any suggestions? Here is the full code so far: ...

Run Class methods through another class

import java.util.Arrays; import java.util.*; class Main { public static void main(String[] args) { } } class List { private static final int NUMINTS = 10; public List(int numints) { int list[]; list = new int[NUMINTS]; } public void fillWithRandom(int list[]) { Random r; r = new Random(); int i; for(i=0; i < NUMI...

Short conditions, java

Hi, i want to test if current char current is not ',', '-', '.' or ' ' Is there a shorter expression for: if((current != ' ') || (current != '.') || ...) any ideas? EDIT: I am just allowed to use the methods nextChar and getChar. I have to loop through the chars. import java.io.FileInputStream; import java.io.IOException; import j...