Definition of an Array
Problem 1:
Develop the program that conducts the following process.
(1) Reads a value for the number of repetitions. The number must be greater than 10. If the user provides a value out of the range, the program askes the user to provide a price again.
(2) Define an array. The number of the array’s element is the same as the number of repetition +1.
(3) Reads a price from the user. The price must be in the range of $10 to $80. If the user provides a price out
of the range, the program askes the user to provide a price again.
(4) Calculate the sales using the formula below.
????? = (?????) ∗ (???? ?????? − (1 + ????? ???????????) ∗ ????? + (????? ???????????) ∗ ??????????′? ?????),
where base demand is randomly drawn from 98 to 102 and price sensitivity is randomly drawn from 5 to 6.
(5) Save the calculated sales into the array defined in step (2).
(6) Repeat (4)-(5) the same number of times as the number of repetition.
(7) Calculate the average of the calculated sales and save it into the array.
(8) Display the average.
Define and use three methods – (1) a method to read user inputs (2) a method to calculate sales the same number of times as the number of repetition (3) a method to display the output.
Important Notes:
• To submit, students copy all the code of the program into a txt or word file (the file should have the suffix .txt, .doc, or docx), name the file as YourFirstName_YourLastName_hw4_Program3”, and submit it via E-Learning Assignments (attach the file)
Problem 2:
A manager of Starbucks franchise wants to investigate market competition levels of local area in a city. The manager assumes that market competition can be measured by a distance between closest branches. Write a program that identifies the nearest pair of Starbucks branches given the location information below:
Use array(s) to save coordinate information of each branch.