homework

Printing a Pattern with While loops and only using three output statements in C

Hello Everyone! I have an assignment for school that is really got the best of me. Here is the question: (2) Write a C program using while loop(s) in combination with only the following three output statements (Each one appearing ONLY ONCE in your program): printf("* "); printf("\n"); printf(“^“); to print the pattern: ...

How to draw a filled square box in Java that is exactly in the center of an applet window?

How do you draw a filled square box in Java that is exactly in the center of an applet window? and when resizing the window, it is centered horizontally and vertically within the applet window? I want it to adapt to the vertical height of the screen but stay square even as the horizontal width edges. If the window is resized to be too na...

TCP Sequence numbers related problem

While opening a TCP connection , the initial sequence number is to be derived using ToD clock that keeps running even when the host is down. The low order 32 bits of the counter of the ToD clock is to be used for the initial seq no. The clock counters increments once per milli second. The maximium packet lifetime is given to be 64s. Wh...

How might I convert Intel 80386 Machine Code to Assembly Language?

I've been given the following task: Consider the following sequence of hexadecimal values: 55 89 E5 83 EC 08 83 E4 F0 31 C9 BA 01 00 00 00 B8 0D 00 00 00 01 D1 01 CA 48 79 F9 31 C0 C9 C3 This sequence of bytes represents a subroutine in Intel 80386 machine language in 32-bit mode. When the instructions in this subro...

How can I solve these issues with my program? (Many issues explained inside)

Hi there. This question is not for the faint of heart and will be time consuming.. I am learning Java, and I was wondering if anyone could walk me through my program to tell me what I did wrong and how I can fix it so that I can learn. My whole program (in case this is needed): http://pastie.org/private/xpbgpypetvfmivcs88gbcq Assignme...

Using string tokenizer to set create arrays out of a text file?

Hey. You may have recently seen a post by me looking for help, but I did it wrong before, so I am going to start fresh and begin at the basics. I am trying to read a text file that looks like this: FTFFFTTFFTFT 3054 FTFFFTTFFTFT 4674 FTFTFFTTTFTF ... etc What I need to do is put the first line into a String as the answer key...

Summing Numerical Character String

Hey everyone, I'm having an issue with my programming assignment where I cycle through a string and sum the integer value of character. As the following code states. Now I pass a string into this subroutine. For example given num := '8888'; Expected Output would be 32 Resulting output is -12 I'm using fpc pascal compiler on a Li...

unpredicted output binary search tree in python

class Node(): def __init__(self,data, left=None, right=None): self.data = data self.left = left self.right = right class BSTree(): def __init__(self): self.root = None def add(self,data): if self.root is None: self.root = Node(data) self.reset() els...

Java List question

I have a program like this public class no_of_letters_count { static int i; public static void main(String[] args) { String sMessage="hello how r u"; String saMessage[] = sMessage.split(""); List sList = Arrays.asList(saMessage); Collections.sort(sList); Iterator i=sList.iterator(); while (i.hasNext()) ...

Why is my array deleting the zeroes from a file I am reading?

Hey hey there. Well, I am attempting to read a text file that looks like this: FTFFFTTFFTFT 3054 FTFFFTTFFTFT 4674 FTFTFFTTTFTF ... etc And when I am reading it, everything compiles and works wonderfully, putting everything into arrays like this: studentID[0] = 3054 studentID[1] = 4674 ... etc studentAnswers[0] = FTFFFTTFFTFT stud...

Using Transactions in Oracle

SELECT executed during the first command T1 is a transaction, in turn, DELETE command (at the time T2) is the first command transaction B. What will be the result of the SELECT statement at the time of T3 (a transaction)? The SELECT statement in T3 will return a row (because Transaction B is not committed yet) ? ...

Algorithm to find a number and its square in an array

Hello I have an array of integers. I need an O(n) algorithm to find if the array contains a number and its square; one pair is sufficient. I tried to do it myself, but I have only managed to find a solution in O(n2). Thanks Edit: like I was asked: I thought about using counting sort, but the memory usage is too big. ...

Understanding Big O

Given the following code, what is the complexity of 3. and how would I represent simple algorithms with the following complexities? O(n²+n) O(n²+2n) O(logn) O(nlogn) var collection = new[] {1,2,3}; var collection2 = new[] {1,2,3}; //1. //On foreach(var i in c1) { } //2. //On² foreach(var i in c1) { foreach(var j in c1) { } } ...

Overwriting Default values in C# structs

For an assignment I have to write a Tribool class in C# using a struct. There are only three possible tribools, True, False, and Unknown, and I have these declared as static readonly. Like this: public static readonly Tribool True, False, Unknown; I need my default constructor to provide a False Tribool, but I'm not sure how to go abo...

haskell matrix scalar multilple question

hi I have a question about haskell coding. Matrices One of many ways to define matrices in Haskell is the list of matrix rows, where a row is a list of double precision oating point numbers: type Matrix=[[Double]] Using this type you should define the following functions (definition of dim is given as an inspirational example). dim...

SQL finding the maximum of all averaged results

I have the relation instructor(ID, name, dept_name, salary). How would I go about finding the name of the department with the highest average salary? ...

Unable to use "execve()" successfully....

The aim of the program is to fork a new child process and execute a process which also has command line arguments.. If i enter "/bin/ls --help". I get the error... shadyabhi@shadyabhi-desktop:~/lab/200801076_lab3$ ./a.out Enter the name of the executable(with full path)/bin/ls --help Starting the executable as a new child process... B...

File can be opened only by root user..Wrong permisssions given, i guess....

My program basically runs a executable file with command line arguments. A child process is forked and the output of the child process is taken in the file "filename". The problem is that the file is made and the data is written but it can only be opened by the root user.. How can make it readable to the user who invoked the program? T...

How to set a BCE year using GregorianCalendar

I have an assignment that converts dates from one calendar system to another. The documentation for GregorianCalendar seems to suggest that you can use dates with BCE years, but I have no idea how. If I simply make the year negative, i.e. GregorianCalendar cal = new GregorianCalendar(-20, 1, 2, 3, 0, 0); System.out.println(cal.getT...

Simple File I/O in C++ - Never Exits This Loop?

Hi, I'm a programming student in my second OOP class, my first class was taught in C# and this class is taught in C++. To get our feet wet in C++, our professor has asked us to write a rather large program with File I/O. The problem is, I have a small part of my program that is not working, at least, not for me. The project requires tha...