Write a program that creates a picture of a mountain panoram

Assignment Help C/C++ Programming
Reference no: EM13839669

Design and implement a C++ program for the following specification.

You are only required to submit one file for this assignment. This is the cpp file, not the project file or the solution file or the executable file. If you submit the wrong file, it will not be possible to mark your assignment.

You may submit your program more than once up to the due date and time, if you decide to change your program after already submitting it. Only the last submission you make will be marked.

Write a program that creates a picture of a mountain panorama from a height profile entered by the user. The following screenshot shows what the output could look like:

361_mountain View.png

The picture shall consist of 5 text lines of length 60. Implement the picture as an array of 5 strings. Every string must initially be filled with 60 space symbols. Space symbols represent the sky. The mountains can be drawn by replacing a single space symbol by a star symbol.

Characters in a string can be set as in the following example:

string greeting = "hallo";

greeting[ 1 ] = 'e'; // now, greeting = "hello"

The shape of the mountains is defined by their height profile. The height profile gives the height of the mountains (measured in text lines) for every column of the picture.

The height profile shall be stored in a one-dimensional array of integers. The array indices correspond to the columns of the picture. The value stored at a certain index gives the height of the mountain in text lines.

At startup, the program displays instructions to the user. Then the program lets the user enter the height profile as a sequence of integer numbers. The user may stop entering numbers early by entering a stop symbol (in the example: the value -1). The stop symbol is not entered in the array. Use the programming technique "partially filled array" from the lecture to implement the height profile.

The program should consist of three functions:
- main
- InputHeightProfile
- DrawMountains

The main function should contain

1. The declaration of a partially filled array for the height profile

2. A call of the function InputHeightProfile

3. A call of the function DrawMountains

The function InputHeightProfile lets the user enter the sequence of numbers. The array storing the height profile should be a parameter of this function. The function should return the number of values entered by the user. The function InputHeightProfile

1. displays the instructions for the user,
2. lets the user enter the sequence of values,
3. lets the user end the sequence early by recognising the stop symbol,
4. and determines the actual length of the sequence (without the optional stop symbol).

The function DrawMountains creates and displays a picture from the height profile. The height profile must therefore be a parameter of this function. The function

1. creates an array of strings, filled with spaces, that represent an (initially empty) image,

2. iterates over all columns, then iterates over a suitable number of rows (according to the height profile), to fill the image with star symbols that represent the mountains,

3. displays the array of strings on the screen.

The program should not crash or produce infinite loops, when too high or too low values are entered in the height profile.

Assignment Requirements

In this assignment you must demonstrate you can use the following programming techniques:

- Use arrays and partially filled arrays
- Use functions and function parameters
- Write helpful code comments that explain the functionality of all parts of the program
- Use descriptive identifiers that support understanding the program
- Use a systematic program layout
- Use only local variables
- Use appropriate loop statements

Assessment

The assessment of your program will be based on the following points. This scheme may change a little, depending on the programs submitted.

- Style
o Program compiles without errors or warnings
o Clean formatting of the source code using tabs, newlines, spaces
o Appropriate use of the techniques listed in the assignment requirements
o Special emphasis will be placed on code comments

- Functionality
o Program is executable
o Program gives helpful instructions to the user
o The user can enter a sequence of numbers
o The sequence can have variable length
o Program deals with obvious errors in the user input
o Correctness of the output
o Program terminates gracefully

Reference no: EM13839669

Questions Cloud

What are some strengths and weaknesses of the proposal : Write an executive summary to present to the board, from which they will make their decision to fund your program or project.
Decision making, problem solving and ethic : Relates to an "Ethical Consideration" from " Decision Making, Problem Solving and Ethics" by Mosley, Pietri and Mosley, designed to reinforce the learning objectives of the course, and in conjunction with the final exam will provide a measure of your..
What are the negative consequences of high unemployment : Why might the misery index consist of measures of unemployment and inflation rates? What are the negative consequences of high unemployment (especially cyclical unemployment if it persists for a long time) and high inflation for the economy?
Prepare a cash basis income statement for the month of jan : Using the transaction data above, prepare (1) a cash-basis income statement, and (2) an accrual-basis income statement for the month of January. Using the transaction data above, prepare (1) a cash-basis balance sheet and (2) an accrual-basis balance..
Write a program that creates a picture of a mountain panoram : Write a program that creates a picture of a mountain panorama from a height profile entered by the user and Implement the picture as an array of 5 strings. Every string must initially be filled with 60 space symbols. Space symbols represent the sk..
Discuss the key elements necessary in formation of contract : The option agreement was in writing and signed by both parties. The agreement referred only to the option, its period, a legal description of the farm, and the purchase price. Thirty days later, Jackson wrote Brady, "I hereby exercise my option to..
Ethical consideration : Your assignment # 2 relates to an "Ethical Consideration" from chapter 3 " Decision Making, Problem Solving and Ethics" by Mosley, Pietri and Mosley, designed to reinforce the learning objectives of the course, and in conjunction with the final exam ..
Find the mean or median and mode : Find the mean or median and mode
Write a cover letter for an advertised job : SOLICITED LETTER: Write a cover letter for an advertised job, or a job about which you have specific knowledge (perhaps a new opening at your current place of employment)

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Describe the output of the series of stack operations

Describe the output of the series of stack operations: push(5), push(3), push(2), push(8), pop(), top(), push(9), push(1), pop(), push(7), push(6), top(), pop(), push(4), pop()

  Calculation of mortgage interest rates

Instruction of pointers and the calculation of mortgage interest rates.

  Program that displays the ball at a random

Write a C++ program that displays the ball at a random location and then makes the ball move down to the bottom of the screen. When the ball reaches the bottom of the screen, it should start these actions over again, appear-ing at another random l..

  Write a program in c that arranges and prints out

When playing poker and other card games (standard 52 cards, excluding the jokers), it is usual to arrange a hand to reflect its values. Write a program in C that arranges and prints out a random hand of ten cards in sorted order by pips values.

  Write a program that uses a function for swapping

Write a program that uses a function for swapping a two numbers. Note: The program requires the user to enter the numbers via the keyboard and determine and display whether a number is odd or even.

  Write a program to determine how long (sec.)

Using the v 2  form of drag, write a program to determine how long (sec.) and how far (m) a 150 gram ball whose radius is 3.5cm would fall before it reached 75% of its terminal velocity. Assume ball falls in air whose density is 1.21 kg/m 3 , has a d..

  Write a c program that recursively determines

Write a C program that recursively determines if a string is a palindrome. Before your program makes the palindrome determination, you must remove all punctuation characters from the string.

  Need to convert this c code to mips

You need to convert this C code to MIPS - The subsequent is a sample output (user input is 2): Enter an integer: 2 The count of the integers that are greater than 2 is: 3 You have to assure the requirements specific in the instruction.

  Write a program with a while loop to print 1 to n in square

Write a program with a while loop to print 1 to N in square brackets. N is an integer input from the user. (i) Write the same program using a for-loop

  Initialize an array and fill the array with the gpa values.

Write a program in java that asks user input (using a loop) for name of 10 student and the corresponding grade point averages (GPAs). Initialize an array and fill the array with the GPA values.

  Programs written with inheritance

Many programs written with inheritance could be written with composition instead, and vice versa. Rewrite the classes Point3D, Sphere and Cylinder using composition rather than inheritance

  A pattern detector has an input

A pattern detector has an input a 4 x 4 matrix whose elements take values a, b, c, or d. The output is 1 if the matrix contains one b surrounded by eight a's and 0 otherwise.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd