Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part I The Part I is done, However I need help with Part II . Please explain in details. thanks You must design 3 algorithms

Part I

The Part I is done, However I need help with Part II . Please explain in details.

thanksimage text in transcribedimage text in transcribed

You must design 3 algorithms, and provide both a flow chart and pseudo code for the algorithms.

Algorithm descriptions:

Given an integer parameter named current_number and two constant global variables: final static int MIN_NUMBER = 1; final static int MAX_NUMBER = 8;

Create an algorithm named forward, that will advance ONE value through a sequence of numbers 1, 2, 3 ... MAX_NUMBER. In other words, when passed a value of 3 in the parameter current_number, it simply returns a 4.

However, when MAX_NUMBER is reached the algorithm should wrap around back and return MIN_NUMBER. The algorithm will NEVER return a value larger than MAX_NUMBER.

Create an algorithm named backward, that will move through a sequence of numbers ... 3, 2, MIN_NUMBER. In other words, when passed a value of 6 in the parameter current_number, it simply returns a 5.

When MIN_NUMBER is reached the algorithm should STOP and return the value MIN_NUMBER. This algorithm will NEVER wrap around.

Create an algorithm named createFileName, that takes a number as input, current_number, and builds and returns a String like "pictureX.gif", where X is the value in the input parameter.

This should fit on 1 sheet of paper. Place the 3 flowcharts (one per method) on one side of the paper and the matching pseudo code next to it or on the other side.

Part II

Implement your algorithms with three methods for this phase. The methods should behave as described in phase 1. The forward method should wrap around when it reaches the last number, the backward method should stop when it reaches the first number.

Add the MIN_NUMBER and MAX_NUMBER constants at the top of your class, you will also need to add a global variable at the top of your class:

final static int MIN_NUMBER = 1; final static int MAX_NUMBER = 8; static int image_number = 1;

The forward() and backward() methods MUST use an input parameter and output a return value, they DO NOT use the above global variable image_number directly, but they should use the constants . The methods are very simple, when the current image number is 3 forward changes it to a 4 and returns it. When the current image number is 6 backward() changes it to a 5 and returns it. The method createFileName() will take a number as input, and returns a String containing a file name like "pictureX.gif". The method createRandomName() has no input, and returns a String containing a file name like "pictureX.gif".

Implement the following methods

public static int forward ( int current_number ) {

// return the new image number

}

public static int backward ( int current_number ) {

// return the new image number

}

// use the constants MIN_NUMBER, MAX_NUMBER, do not use hard coded 1 or 8

public static String createFileName ( int current_number ) {

// return a filename like pictureX.gif

}

public static String createRandomName ( ) {

// return a filename like pictureX.gif

// using a RANDOM number between MIN_NUMBER and MAX_NUMBER

}

public static void showMenu ( ) {

// write a loop

// Display a menu, with options 1 .. N for each method above, and an exit option

// get user input and call the correct method using a SWITCH

// print out the NEW image number everytime the value changes

}

public static void main ( String [] args) {

// call showMenu

}

The menu should have options for calling forward(), backward(), createFileName () and createRandomName ( ). Be sure to use a parameter when calling the functions, then use the return value to update the global image number. At this point, your program will show the menu, call the methods and print onto the console the new image number everytime it changes.

Flow Chie t PSESD CODE START FORWARD dt indude lastream void main C) No Yes END END BACKWARD ALG ORITHM Cout STARD #undude ung voldl main ( ut badcword un 72y namaspa std Input t 78 END else extt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions