Write program that creates a picture of a mountain panorama

Assignment Help Programming Languages
Reference no: EM131321253

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: EM131321253

Questions Cloud

Diameter spread in the beam of bullets : Bullets of mass2.2g are fired in parallel paths with speeds of216m/s through a hole2.0mm in diameter. How far from the hole must you be to detect a1.4cm diameter spread in the beam of bullets?
Buoyant force acting : (a) What is its weight? (b) What is the buoyant force acting on it? (c) What is the size and the direction of the net force on it?
Show corporate income tax calculations : Complete the previous template that has the respective tax forms and schedules required to complete the return. Complete all of the parts of your respective business tax return for which there is information.
Should the null hypothesis be rejected : A friend of yours reports a study that obtains a p-value of .02. What can you conclude about the finding? List two other pieces of information that you would need to know to fully interpret the finding.
Write program that creates a picture of a mountain panorama : 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:
Discuss the challenges that organisations face : Write the given essay assignment.- Discuss the challenges that organisations face in aligning their reward and performance appraisal systems.
Repeats this trip the following weekend : Suppose that one weekend day a hiker exerts 200 Watts of power while ascending 300 meters on a steep trail without a pack. The hiker repeats this trip the following weekend but is carrying an additional 10 kilograms in a pack. How much longer shou..
Acceleration and the change in time : An elevator is moving downwards at 4m/s when suddenly someone hits the stop button and it travels another 2.9 m before coming to a rest. Please solve for the acceleration and the change in time.
Design and conduct if possible an archival research study : Design, and conduct if possible, an archival research study. Consider what type of information you will look for, how you will find it, and how it should be content coded.

Reviews

Write a Review

Programming Languages Questions & Answers

  Describe the necessary formulas and sample calculations

Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input

  Using the irvine32 library functions

Create 32 random points which have (x, y) co-ordinates

  Create class uses element array of digits to store integers

Create a class HugeInteger which uses a 40-element array of digits to store integers as large as 40 digits each. Provide methods input, output, add and subtract.

  Write a program that will allow the user to sum two integers

Write a program that will allow the user to sum two integers up to 20 digits big. The integers should be stored in a string with no more than size 20. The integers will be read in as a string, not an integer.

  Two-dimensional array to store weekly hours for employees

Assume the weekly hours for all employees are stored in two-dimensional array. Each row records emaployee's seven-day workhours with seven columns.

  Design a program that asks for the price of each item

Please provide a pseudocode and flowchart for the program that follows the guidelines of good program design, like meaningful variable names and thoroughly commented code.

  Write a program takes input from a user in the phone

Program takes input from a user in the phone of a phone number, 7 digits plus the hyphen. It then checks whether a user has entered Q to quit, if 0 or 555 are the begging sequence of inputs (if they are the program alerts the user to an error with..

  Write accessors for each of the declared class variables.

Read the file and display in the listbox each record splitting out the fields, eliminating the comma delimiters and placing spaces between the fields.

  Write a program that prompts the user for a positive integer

Write a program that prompts the user for a positive integer greater than 1. The program should then output either "prime" if the given number is a prime or "composite" otherwise. Recall that an integer is prime if and only if its only divisors are 1..

  Develop applications in-house rather than outsourcing

Discuss where it might make more sense for each: off-shoring, on-shoring, and near-shoring - Discuss the benefits and drawbacks to this approach, from both the company and the developer perspective.

  Write a lex program that converts a le to pig latin

Write a Lex program that converts a le to Pig Latin." Specially, assume the le is a sequence of words (groups of letters) separated by whitespace.

  Write program to calculate tips for services rendered

Write program to calculate tips for services rendered. The program must request person's occupation, amount of the bill and the percentage tip as input

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