Write a program that creates a picture of a mountain

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

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:

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

Do not use the following techniques:

- Do not use the C++ keywords break (except for a switch statement), return (except at the very beginning or end of a function), exit, goto, or continue.

- Do not use templates or dynamic memory allocation.

Reference no: EM13845069

Questions Cloud

Advise jack and jill of their income tax consequences : Advise Jack and Jill of their income tax consequences arising out of the above information under both the diminishing value method and the prime cost method (if relevant) for the year ended 30 June 2015.
Identify factors that can cause change initiatives to fail : Identify factors that can cause change initiatives to fail and the five pillars that can cause them to succeed. Highlight an organization that failed to adapt and evaluate which of these factors and pillars were demonstrated by this organization.
Production of a chemical compound : The production of a chemical compound requires a curation period of 5.5 hours +/-.5 hours, a speed of 130 rpm +/- 20 rpm to obtain an acceptable product. If we want to know with a 95% confidence level, if these variables affect the production yiel..
Explain whether the creditors will prevail : Creditors of the partnership seek to hold Madison and Tilson personally liable for the $30,000. Explain whether the creditors will prevail.
Write a program that creates a picture of a mountain : Write a program that creates a picture of a mountain panorama from a height profile entered by the user -  The height profile shall be stored in a one-dimensional array of integers. The array indices correspond to the columns of the picture. The va..
Graphs and statistics using software : The following lab is to give you a chance to generate your own graphs and statistics using software.
Graphs and statistics using software : The following lab is to give you a chance to generate your own graphs and statistics using software.
Why jet airways better than kingfisher : Why kingfisher shutdown and why jet airways better than kingfisher. which strategy used jet airways how kingfisher airlines can use that strategy. give recommendation and conclusion.
Discuss narcoterrorism and its effects on terrorist acts : Discuss propaganda and the presentation of one-sided statements. Who are the groups that initiate propaganda? What are their objectives? Discuss "narcoterrorism" and its effects on the financing of terrorist acts

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program that asks user to enter

Write a program that asks user to enter the size of the matrix (rows and column) then, it asks the user to enter the elements of two matrices and finally it adds two matrix and displays the result in C language.

  Write a function that takes two positive integer arguments

Write a function named "g_c_d" that takes two positive integer arguments and returns as its value the greatest common divisor of those two integers. If the function is passed an argument that is not positive (i.e., greater than zero).

  Implement a graphics system that has classes

Implement a graphics System that has classes for various figures: rectangles, squares, triangles and circles. A rectangle has data members height, width, color , and center point. A square has center point and an edge and color

  A real-life plc programming task

In lieu of a final exam, you are required to complete a final, capstone project for this course. The final project ties together everything covered in the course and offers you the opportunity to apply what you have learned to a real-life PLC program..

  Implement a second-order low-pass filter

Implement a second-order low-pass filter using the finite difference method. The finite difference method is a useful mathematical method that is used to numerically solve differential equations.

  Create a function that will accept a scalar value

Create a function that will accept a scalar value for the radius of the cylinder and end caps and will accept an array for the height of the cylinder.

  Complete the design and implementation

Complete the design and implementation of the class customerType defined in the Programming Example Video Store. b. Design and implement the class customerListType to create and maintain a list of customers for the video store.

  Write a recursive function squares

Write a recursive function squares that takes a list of numbers, and returns a new list of the squares of those numbers.

  Write code that will create a two dimensional array

show how you would determine from within the hitWalker method how many columns are in this array. You may assume the array is perfectly rectangular and is not "ragged". Write code that will create a two dimensional array representing the following ma..

  Prompts the user to enter an integer

Write the code that prompts the user to enter an integer between 1 and 20 (including 1 and 20), reads the value using cin, and then prints the value that they entered in a statement that begins with "You entered a ". Save this version in a separate l..

  Struct definition to represent the data of a person''s bank

Define a struct definition to represent the data of a person's bank account. There will be one string for the name, and two doubles for balance and interest rate. Declare two variables of this new type in the main function. Modify the values of each ..

  The function should return a value

The function should return a value of 1 when it is given a valid score to process and 0 when the received value is out side of the 0-10 range. In this case it should print a waring message on the screen

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