Search

Custom Search

Thursday, November 25, 2010

computer science assignment

Operating Systems Concepts
CSci 474
Project #2: Threads and semaphores
Due Date: 11:55PM, December 1, 2010
I. Project Organization
This project will study multiple thread programming, using semaphores and POSIX.
You should do the following pieces to complete your project. Each piece is explained below:
• Design 10 points
• Code 25 points
• Output 10 points
• Summary 5 points
Design
List each semaphore with its purpose and initial value. Provide pseudocode for each thread.
Code
Your code should be nicely formatted with plenty of comments. The code should be easy to read,
properly indented, employ good naming standards, good structure, and should correctly implement the
design.
Output
Output will be graded by running your program on the UNIX machines in Lab 244.
Summary
The summary section should discuss your simulation, any difficulties encountered, what was learned,
and results. It should be at least one page.
II. Project Description
You must complete this project based on POSIX.
This project simulates a game through multithreading. The following rules apply:
1. The main thread creates a server thread and two player threads.
2. A player thread is blocked until a server thread is created - the player thread cannot join a game
until the server thread is created.
3. Each game must have exactly two players -- the server thread cannot start the game until two
players join the game.
4. After the game starts, each player thread randomly generates an integer and passes this integer to
the server thread.
5. The server is waiting for randomly generated integers from two players.
6. The player threads wait for the result from the server.
7. The server thread compares integers and notifies two player threads the result (the thread which
generates a larger integer wins). Game ends.
Your output must show all activities in each thread.
For example:
Main thread creates the server thread.
Main thread creates the player thread 1.
Main thread creates the player thread 2.
Server threat starts.
Player thread 2 starts.
Player thread 1 starts.
Player thread 1 joins the game.
Player thread 2 joins the game.
Server thread starts the game.
Player thread 2 passes 123 to the server.
Player thread 1 passes 234 to the server.
Server announces player 1 wins the game.
GAME OVER.
III. Project Guidelines
Submitting
Submit your project on Blackboard. Include in your submission the following files:
1) A Word document for the written pieces of the project
2) Your source files
NO hardcopy submission. Late submission will NOT be accepted.
Cheating
All work must be your own. If cheating is detected, all parties involved will be given a zero for the project
and the penalty will be documented on a form that you must sign. You may be referred to the Dean's
office for further discussion.
Grading
The written portions will be graded subjectively based on completeness and quality. The code will be
graded based on points allocated for each key part of the processing as determined by the instructor. The
output will be graded based on expected results for the runs.

computer science assignment

Operating Systems Concepts
CSci 474
Project #2: Threads and semaphores
Due Date: 11:55PM, December 1, 2010
I. Project Organization
This project will study multiple thread programming, using semaphores and POSIX.
You should do the following pieces to complete your project. Each piece is explained below:
• Design 10 points
• Code 25 points
• Output 10 points
• Summary 5 points
Design
List each semaphore with its purpose and initial value. Provide pseudocode for each thread.
Code
Your code should be nicely formatted with plenty of comments. The code should be easy to read,
properly indented, employ good naming standards, good structure, and should correctly implement the
design.
Output
Output will be graded by running your program on the UNIX machines in Lab 244.
Summary
The summary section should discuss your simulation, any difficulties encountered, what was learned,
and results. It should be at least one page.
II. Project Description
You must complete this project based on POSIX.
This project simulates a game through multithreading. The following rules apply:
1. The main thread creates a server thread and two player threads.
2. A player thread is blocked until a server thread is created - the player thread cannot join a game
until the server thread is created.
3. Each game must have exactly two players -- the server thread cannot start the game until two
players join the game.
4. After the game starts, each player thread randomly generates an integer and passes this integer to
the server thread.
5. The server is waiting for randomly generated integers from two players.
6. The player threads wait for the result from the server.
7. The server thread compares integers and notifies two player threads the result (the thread which
generates a larger integer wins). Game ends.
Your output must show all activities in each thread.
For example:
Main thread creates the server thread.
Main thread creates the player thread 1.
Main thread creates the player thread 2.
Server threat starts.
Player thread 2 starts.
Player thread 1 starts.
Player thread 1 joins the game.
Player thread 2 joins the game.
Server thread starts the game.
Player thread 2 passes 123 to the server.
Player thread 1 passes 234 to the server.
Server announces player 1 wins the game.
GAME OVER.
III. Project Guidelines
Submitting
Submit your project on Blackboard. Include in your submission the following files:
1) A Word document for the written pieces of the project
2) Your source files
NO hardcopy submission. Late submission will NOT be accepted.
Cheating
All work must be your own. If cheating is detected, all parties involved will be given a zero for the project
and the penalty will be documented on a form that you must sign. You may be referred to the Dean's
office for further discussion.
Grading
The written portions will be graded subjectively based on completeness and quality. The code will be
graded based on points allocated for each key part of the processing as determined by the instructor. The
output will be graded based on expected results for the runs.

computer science assignment


write to me Pollard Rho's algorithm for factorization on Java "all coding with a result"

computer science assignment


My project is about a volatily surface built from a Black and Scholes class. If we don't have the volatility, we have to find the implied volatility and then use that to have the volatility surface. 
 
 
I have a HW of a volatility surface on C++. I have already started but instead of improving my program has lots and lots of errors. Instead of having my program done from someone else, I would like to have a tutor who can work with me in order to solve those errosr and get the program running. 
 
I have already started but I have many errors and I think it's not working properly. 
Enclosed is what I have done so far. This is a project in groups so a classmate sent his files:
* QuantLib
* Calendar
* date
* exception
* FavFive
* yieldcurve
* FixedIncome
* Interpolation
* Number_theory
* strings
 
My files are:
1.  BlackScholes including the greeks that are already in the program. In this class, time is the time at which the option starts, this is useful for the forward starting options
2.  Normaldist 
3.  VolSurface 
 
So, what I have to do is to focus on MY files, trying not to change too much the other ones. 
 
Some of the problems I had:
 
* When I compiled the code and had tests on main I got many errors saying there were undefined reference methods. 
* It would be also helpful to get a program that reads from a .txt file all the info and builds the vol surface (enclosed is an example of how the data is).
* Black and Scholes class: 
    - It would be better to have a Newton Raphson algorithm to find the implied volatility and that the implied volatility is a method by itself. 
 
* The Black and Scholes and Vol Surf classes are supposed to call the yieldcurve class to use the interest rates for the valuation of the asset. Even though I was working at the beginning with time and expiration as doubles, I prefer to have actual dates: MMDDYYYY as appears in the date class. There might be also methods in the class that use the time as doubles in case we need it but for building the volatility surface I think it's more useful to have the actual calendar date (date and calendar have some useful functions that do that but it's good that BlackScholes and VolSurf classes incorporate those methods in case the user inputs time and expiration as doubles). 
I didn't really understand my friend's code for calendar and date classes but there are some good examples in main. 
 
For the volatility surface, I wanted to apply a quadratic interpolation, so I called the interpolation class. There is an example in main:
 
INT.SetSpline(2,0) -> This is the default case for that quadratic interpolation
 
Please include tests in main to check that the code runs correctly and also to make sure I understand how it works. 
 
According to the project, the volatility object should offer the following methods
Variance (S, K, t) variance at time t for underlying S, strike K
Volatility(S, K, t) volatility at time t for underlying S, strike K
Forward Volatility (S, K, t, T) volatility at time t (time t from now) and period T (expiration) for underlying S, strike K
 
Plots of the volatility surface that offer the option of the specific date (i.e. monthly expirations from Dec2010 until Mar2012) or T=0 to T=2 years from today and specific strikes (ie K= 180, K = 200, etc) or (from S/K=0.3 to S/K=2)
 
If you think my BlackScholes and volSurf should be redesigned and changed drastically, please feel free to do it as long as I can understand the code and it's not very advanced for me to understand it. The best thing is to be able to have a matrix or a vector of vectors that my classmates can call if they need the Volatility(S,K,T). In case we agree on the price, design and deadline. Let me know if you need to change files other than 1,2,3.
 
I'm sorry if the explanation was too long, but in the end I think it wouldn't be that complex if I was better at programming on C++. 

computer science assignment



you wrote the function words() which chops a sentence
into words and stores them into a 2D char array.
In this homework, you are required to write a function that takes a
string as its input, chops the sentence into words, and for each
word, capitalizes the rst letter and forces all other letters to be
lower case. Fox example, if the input parameter is `this is an
american TRADITION', the return value of your function should
be a valid 2D char array:
This
Is
An
American
Tradition
Your function will call words(), and the words() function can be
found on P. 283 of your textbook. Submit 3 les: words.m, your
function le, and a driver program that has input() function to get
input sentence from user.

computer science assignment


Please have someone to write a DETAIL step by step solution with solution and explanation. Thank You
Lab: 
Part A: Video Game Player Program
Step 1: Requirements
Write a program to do the following.  In main declare a Player Name Array and a Score Array.  Declare the size of the arrays to be 100.  In the InputData function input the player name and score into the arrays for an unknown number of players up to 100.  In the DisplayPlayerData function display the name and score of each player.  In the CalculateAverageScore function calculate the average score and return it by value.  In the DisplayBelowAverage function display the name of the player and score for any player who scored below the average.  Do not use global variables.  
Output from Program: 
Enter Player Name (Q to quit): Bob
Enter score for Bob: 3245
Enter Player Name (Q to quit): Sue
Enter score for Sue: 1098
Enter Player Name (Q to quit): Dave
Enter score for Dave: 8219
Enter Player Name (Q to quit): Pat
Enter score for Pat: 3217
Enter Player Name (Q to quit): Q   
Name   Score
Bob        3245
Sue        1098
Dave       8219
Pat        3217 
Average Score: 3944.75 
Players who scored below average   
Name    Score
Bob        3245
Sue        1098
Pat        3217
Press any key to continue . . . 
Step 2: Processing Logic
Using the pseudo code below, write the code that will meet the requirements:  
Main Function   
Declare the player name and score arrays, number of players, and average score.    
Call the InputData function   
Call the DisplayPlayerData function   
Call the CalculateAverageScore function and assign the returned value in average score   
Call the DisplayBelowAverage function  
InputData function    
While the number of players is less than the length of the array        
Prompt for the player's name        
If the user entered Q, break out of the loop        
Prompt the user for the player's score         
Add 1 to the number of players    
End-While 
DisplayPlayerData function    
Display the name and score of each player  
CalculateAverageScore function    
Add up the scores and divide by the number of scores to calculate the average score    
Display the average score    
Return the average score to main 
DisplayBelowAverage function    
Display the names and scores of all players who scored below the average score 
Step 3: Create a new project
Create a new project and name it LAB5A. 
Write your code using the Processing Logic in Part A Step 2.  Make sure you save your program.
Step 4: Compile and Execute
a)    Compile your program.  Eliminate all syntax errors.  
b)    Build your program and verify the results of the program.  Make corrections to the program logic if necessary until the results of the program execution are what you expect. 
Step 5: Print Screen Shots and Program

1.    Capture a screen print of your output [Do a PRINT SCREEN and paste into an MS Word document.]
2.    Copy your code and Paste it into the same MS Word document that contains the screen print of your output.
3.    Save the Word Document as Lab05A_LastName_FirstInitial    
END OF PART A
 
    


Part B: Pig Latin
Step 1: Requirements
Write a program that will input a phrase and convert it to pig latin.  Put each word in a separate element of a string array.  Remove the first letter from each word and concatenate it to the end of the word followed by "ay".         
Sample Output from Program: 
*** You will be prompted to enter a string of  ***
*** words. The string will be converted into   ***
*** Pig Latin and the results displayed.       ***
*** Enter as many strings as you would like.   *** 
Enter a group of words or ENTER to quit: DeVry is a wonderful school 
Original words: DeVry is a wonderful school
New Words: eVryDay siay aay onderfulway choolsay 
Enter a group of words or ENTER to quit: The Cowbows are going to the Superbowl 
Original words: The Cowbows are going to the Superbowl
New Words: heTay owbowsCay reaay oinggay otay hetay uperbowlSay 
Enter a group of words or ENTER to quit: 
Step 2: Processing Logic
Using the pseudo code below, write the code that will meet the requirements.  
Main function    
Display the heading    
While the condition is true            
Prompt the user for group of words or Enter to quit            
Display original words            
Call function pigLatinString( )    
End while 
pigLatinString( ) function    
Declare and initialize string variables len, counter, start, begin, word and newString    
While condition is true            
Call find() and pass a space and start as parameters and return the returned value            
to start            
if start equals to string::npos            
jump outside the loop permanently            
call substr() function            
display the word            
update newString            
increment start by one            
assign start to begin   
End While
Call substr()
Update newString
Return newString 
Step 3: Create a new project
Create a new project and name it LAB5B. 
Write your code using the Processing Logic in Part B Step 2.  Make sure you save your program.
Step 4: Compile and Execute
a)    Compile your program.  Eliminate all syntax errors.  
b)    Build your program and verify the results of the program.  Make corrections to the program logic if necessary until the results of the program execution are what you expect. 
Step 5: Print Screen Shots and Program

1.    Capture a screen print of your output [Do a PRINT SCREEN and paste into an MS Word document.]
2.    Copy your code and Paste it into the same MS Word document that contains the screen print of your output.
3.    Save the Word Document as Lab05B_LastName_FirstInitial    
END OF LAB

computer science assignment


Design a simple sequence detector to output a 1 whenever a combination of 0110 is encountered in the input sequence.

what will be the moore and mealy machines for this?