homework

This ajax is working fine can you help me to convert this into Comet...

Hello i am learning comet and i am facing problem since most of the online tutorials about comet contains js prototype so can you convert this code into long polling.... thank you... -pradeep //This is my js var xmlhttp function ajax(str) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support AJAX!...

program to find the sum of digits

I can't figure out the problem in this: #include<stdio.h> int main() { int a,b,count ; count =0; printf("enter the value for a "); scanf("%d ",&a); while(a>0) { b=a%10; count=b+count; a=a/10; printf ("hence the simplified result is %d",count); } return 0; } ...

Syntax analysis question

In school we were assigned to design a language and then to implement it, (I'm having so much fun implementing it =)). My teacher told us to use yacc/lex, but i decided to go with java + regex API, here is how the the language I designed looks: Program "my program" var yourName = read() if { equals("guy1" to yourName) } print("hello m...

Transposition or Substitution Ciphertext? (monoalphabetic or polyalphabetic?)

Hi, We have a ciphertext with IC=0.0685. We want to find out the class descriptor (mono-alphabetical/poly-alphabetical/transposition). I have applied the 2 probabilistic tests to try and guess what class it belongs to. These tests are: Ratio of vowels to total (<25%) then more likely a substitution %ETAOS in text (<35%) then more likel...

Quantum Tic Tac Toe AI

In my data structures class, we've been assigned a project in which we are required to make a fully functioning Quantum Tic Tac Toe game in which a player faces a bot that plays to win. The professor suggested we use a game tree in our AI. However, as usual, I am looking for something more challenging. Can anyone suggest a better, mor...

Does TDD really stop gold plating?

Questions that I want answers for... 1) Propose one or more mechanism, which could be used to extend TDD to estimate the level of gold plating that exists in an arbitrary Java program. 2) What estimations would your mechanism provide the quantity the level of gold plating? 3) What evidence can you provide (if any) to justify or argue ...

Understanding an error message while writing code for a Fibonacci program

My apologies in advance should I butcher any Python vocabulary, this is my first programming class and we are not permitted to post or share our code. I will do my best to explain the problem. I am defining my function as variable one and variable two. I then gave values to both variables. I used a for statement with a range value; cr...

Just Want to know what this error message really means!

expected unqualified-id before '{' Where is this error on my code? Thanks everyone! #include <iostream> using std::cout; using std::endl; //function prototypes void findsmallest (int[], int &); void findsmallest (int scores [], int & min); int main() { //declare variables int smallest = 0; int scores[20] = { 90, 54...

C Programming (GPA Calculator)

Very stuck on this problem. I FINALLY got the average to come out, but it gives it as negative 32 million or something. Here is my code: #include <stdio.h> #include <stdlib.h> int main() { float fArray[30]; int choice = 0; int x = 0; float total = 0; float avg = 0; printf("1. Calculate GPA Average"); printf("\n2. Enter GPA"); pri...

dynamic programming: finding largest non-overlapping squares

I really have no idea how to do this using dynamic programming: Problem: I need to find the 2 largest non overlapping squares of a table For example: 5 6 R F F R R F F F F F F F R R F F F F F F F F F F F F F F F F The numbers 5 and 6 are the number of rows and columns respectively, and “R” means reserved and “F” means free. In this ca...

Print number in words

Hi, I am trying code to print a three digit number in words. But this isn't working if first two digits from right are between 11 & 19 (both including). Any help? package com; import java.util.Stack; public class TestMain { public static void main(String[] args) { Integer i=512; int temp =i;int pos=1; Stack<String> stack=new Stack<...

Prolog mystery(c,[a,b,c,d],Z).

I think the answer is 3 but I am not sure, can anyone provide some help? Suppose the following two statements are entered into Prolog: mystery(X,[X|L],L). mystery(X,[Y|L],[Y|M]) :- mystery(X,L,M). What would Prolog return if one then gives it the following goal? ?- mystery(c,[a,b,c,d],Z). ...

Simple problems with MATLAB

I have three questions: 1) I want to compute the following using MATLAB: 11^2 + 13^2 + 15^2 + ... + 109^2 + 111^2 I have tried using: x = [11^2 13^2 15^2 ... 109^2 111^2] z = cum(single(x)) but I got an error... 2) I want to display '2 sin/pix'... I tried: tittle('2 sin/pix') Can I represent the display without displaying it...

MATLAB: sum of matrix elements

Given the matrix: A=[1 2 3; 4 5 6; 7 8 9] how would you use the for loop to compute the sum of the elements in matrix? write a one line MATLAB command using the function sum() to sum the matrix elements in A My answer: 1) for j=1:3, for i=j:3, A(i,:) = A(i,:)+A(j+1,:)+A(j+2,:) end end 2) sum(A) Is that the c...

Loops in MATLAB

How many times will the following loop execute? x=-4 while x <8 x=x+3 end Can anyone explain it to me? ...

multiplicative inverse?!?!?

Hi, I know that an affine cipher substitutes BD with SG. I need to find the encryption formula, in the form y = a x + b, where a and b are coefficients. From the information above I end up having to equations: a+b=18 and 3a+b=6 So I am working like this: a+b=18 and 3a + b = 6-> 3a+18-a=6->  2a= 6-18 -> 2a=14 (cuz it is mod 26) b=18-a ...

Accented/umlauted characters in C?

I'm just learning about C and got an assignment where we have to translate plain text into morse code and back. (I am mostly familiar with Java so bear with me on the terms I use). To do this, I have an array with the strings for all letters. char *letters[] = { ".- ", "-... ", "-.-. ", "-.. ", ".", "..-." etc I wrote a function for ...

Is this a mistake in my Computer Architecture book?

I'm working on my HW for computer architecture and I came across the following problem: A = 247 B = 237 1) Assume A and B are signed 8-bit integers stored in two's complement format. Calculate A + B using saturating arithmetic. The result should be written in decimal. Show your work. 2) Assume A and B are signed 8 bit int...

Generating a 160bit string which is stored in an array.

Hello! I'm trying to generate a random 160bit string which is supposed to be stored in a character array named str[20]. It's obvious that the array holds 20 characters. How can I change the 160bits into 20 characters/numbers? I'm trying to do this in C.. Any help is greatly appreciated as I've ran out of ideas and then helpdesk at my uni...

MATLAB and function

I want to calculate the function y(t) from the equation: y(t) = -3t^2+5, t>=0 y(t) = 3t^2+5, t<0 for -9 <= t <= with the step-size 0.5 and I want to plot it by using MATLAB. I approach this question in two ways: First t=0:0.5:9 y=-3*t^2+5 t1=-0.00000000001:0.5:-9 y1=3*t^2+5 plot(t,y,t1,y1) Second by using loop t=-9:0.5:9 if(t...