Question: C# only Create an application that lets you enter a list of positive and zero integers. That is, if you enter a negative number,the application

C# only

Create an application that lets you enter a list of positive and zero integers. That is, if you enter a negative number,the application will be terminated. These numbers represent the altitudes. This application will count the number

of hills while you are entering a number. A hill is made up of at least three different altitudes, in which these numbers must go up and then come down. Additionally, a plateau (flat surface) can exist on the top of the hill, where all the numbers are the same.

Hints: you may need to keep track of your statusesan uphill, a plateau, and a downhillin addition to counting the number of hills. You may also need to keep track of the previous number (see second line of example) in addition to recording the current number. For example: 2, 3, 4, 5, 5, 5, 5, 4, 3, 1 is a hill, and 1, 2, 3, 4, 5, 5, 6, 7, 6, 4, 2 is still a hill because even if you are on a flat at 5 and 5, you can still climb uphill. Also, 1, 2, 1, 3, 1, 4, 1 counts as 3 hills (1, 2, 1 is one; 1, 3, 1 is another; 1, 4, 1 is the third hill) so you will need to keep track of the previous number. 1, 2, 3, 4, 5, 6 is not a hill because it is not going downhill, and 4, 3, 2, 1, 3, 5 is not a hill because there are no hills there.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!