Define a class called counter
Course:- Software Engineering
Reference No.:- EM13313221

Assignment Help
Expertsmind Rated 4.9 / 5 based on 47215 reviews.
Review Site
Assignment Help >> Software Engineering


The Fibonacci numbers are defined by the sequence:
f1 = 1
f2 = 1
fn = fn-1 + fn-2.
Reformulate that as
Fold1 = 1;

After that, discard fold2, which is no longer needed, and set fold2 to fold1, and fold1 to fnew. Repeat an appropriate number of times.
Implement a program that prompts the user for an integer n and prints the nth Fibonacci number, using the above algorithm.

Problem 2:

Write a program that prints a multiplication table, like this:
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
10 20 30 40 50 60 70 80 90 100

Problem 3:

The Drunkard's Walk. A drunkard in a grid of streets randomly picks one of four directions and stumbles to the next intersection, then again randomly picks one of the four directions, and so on. You might think that on average the drunkard doesn't move very far because the choices cancel each other out, but that is actually not the case.

Represent locations as integer pairs(x,y). Implement the drunkard's walk over 100 intersections, starting at (0,0) and print the ending location.

Problem 4:

Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whole number. Include methods to set the counter to 0, to increase the counter by 1, and to decrease the counter by 1. Be sure that no method allows the value of the counter to become negative. Also include an accessor method that returns the current count value, as well as a method that displays the count on the screen. Do not define an input method. The only method that can set the counter is the one that sets it to zero. Write a program to test your class definition. (Hint: you need only one instance variable).

Problem 5:

Consider a class that could be used to play a game of hangman. The class has the following attributes:
• The secret word
• The disguised word, in which each unknown letter in the secret word is replaced with a question mark (?). For example, if the secret word is abracadabra, and the letters a , and b have been guessed, the disguised word would be ab?a?a?ab?a
• The number of guesses made
• The number of incorrect guesses

It will have the following methods:
• MakeGuess(c) guesses that character c is in the word
• getDisguisedWord returns a string containing correctly guessed letters in their correct positions and unknown letters replaced with ?
• getSecretWord returns the secret word
• getGuessCount returns the number of guesses made
• isFound returns true if the hidden word has been discovered.

Perform the following actions:
• Write a method heading for each method.
• Write preconditions and postconditions for each method.
• Write some Java statements that test the class.
• Implement the class.
• List any additional methods and attributes needed in the implementation that were not listed in the original design. List any other changes made to the original design.
• Write a program that implements the game of handgman, using the class you wrote for part d.

Problem 6:

Consider a class Movie that contains information about a movie. The class has the following attributes:
• The movie name
• The MPAA rating (e.g. G, PG, PG-13, R)
• The number of people that have rated this movie as a 1 (Terrible)
• The number of people that have rated this movie as a 2 (Bad)
• The number of people that have rated this movie as a 3 (OK)
• The number of people that have rated this movie as a 4 (Good)
• The number of people that have rated this movie as a 5 (Great)

Put your comment

Ask Question & Get Answers from Experts
Browse some more (Software Engineering) Materials
Given a set of process and resources, set of requested resources for each process, and number k, is it possible to assign resources to processes so that at least k processes
Define an enterprise system and explain how enterprise software works. Select one type of Enterprise system and describe how it helps businesses achieve operational excellen
For the company assigned, draw a systems flowchart.- If any exception routines are described in the narrative, they should be shown on a separate page, so that the exceptio
Develop a visual rendering of each approach using Microsoft Visio or its open source alternative, Dia. Note: The graphically depicted solution is not included in the require
The lecture and text discussed challenges and problems which Software Engineers have dealt with in the past. Investigate what you consider to be the challenges facing softwa
Construct training data files using the training image data for three different bin numbers and construct the five different classifier models using each training data file.
End users must be involved in database design, but only to  degree. What are you are your toughts do you agree or did agree why or why not.
Develop a high level component view of your architecture and demonstrate how it will support the CCRD use case with a ‘use case trace'. Show how your architecture will map t