Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

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.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92075854
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Programming Language

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As