Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you. Phase 1 You must design 3 algorithms , and

Help with programming in C++

Phase 1 is complete, please help with phase 2. Thank you.

Phase 1

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: const int MIN_NUMBER = 1; const 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 function) on one side of the paper and the matching pseudo-code next to it or on the other side.

Phase 2

Implement your algorithms with three functions for this phase. The functions should behave as described in phase 1. The forward function should wrap around when it reaches the last number, the backward function 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:

const int MIN_NUMBER = 1; const int MAX_NUMBER = 8; int image_number = 1;

The forward() and backward() functions 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 functions 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 function createFileName() will take a number as input, and returns a string containing a file name like "pictureX.gif". The function createRandomName() has no input, and returns a string containing a file name like "pictureX.gif".

Implement the following functions

int forward ( int current_number ) { // return the new image number } 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 string createFileName ( int current_number ) { // return a filename like pictureX.gif } string createRandomName ( ) { // return a filename like pictureX.gif // using a RANDOM number between MIN_NUMBER and MAX_NUMBER } void showMenu ( ) { // write a loop // Display a menu, with options 1 .. N for each function above, and an exit option // get user input and call the correct function using a SWITCH // print out the NEW image number everytime the value changes } int main () { // call showMenu return 0; } 

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 functions and print onto the console the new image number every time it changes.

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_2

Step: 3

blur-text-image_3

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

Explain how to reward individual and team performance.

Answered: 1 week ago

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago