INSTRUCTIONS 1. Prompt the user for the number of participating units and expected peak demand hours...

Question:

INSTRUCTIONS 1. Prompt the user for the number of participating units and expected peak demand hours 2. Create two arrays: O A String array called unitstatus, with an array element count equal to the number of participating units o An int array called unitCredit, with an array element count equal to the number of participating units O HINT: make sure you understand the difference between array size (element count) and element index (position) 3. Initialize the arrays, setting each element of the unitStatus array to "ON", and each element of unitCredit to zero o THINK: Think about this for a minute. This requires repeated actions (since you want to do the same thing to each element of each array), so you'll need a loop. What type of loop would work best for this? A while loop or a for loop? 4. For now, work continue to work as if you are solving for a single hour of demand: Shut down the number of units needed to meet demand: To determine how many units to shut down, generate a random integer between 0 and the total number of A/C units . HINT: Be sure that your code allows for 0 units to be needed, as well as the maximum number of units available. For example, if there are 3 units available, then the set of possible values should be 0, 1, 2, and 3. Be sure to test this carefully! O Print the number of units to be shut down in this hour o Mark units as shut down (with credit), starting with the first unit and working sequentially through the array until you have turned off enough units.
run: Enter the number of units: Enter the number of hours: In hour 1 we need to shut down 2 units: Unit 0 is OFF with credits: 1 Unit 1 is OFF with credits: 1 In hour 2 we need to shut down 0 units: Unit 0 is ON with credits: 1 Unit 1 is ON with credits: 1 In hour 3 we need to shut down 1 units: Unit 0 is OFF with credits: 2 Unit 1 is ON with credits: In hour 4 we need to shut down 0 units: Unit 0 is ON with credits: 2 Unit 1 is ON with credits: 1 In hour 5 we need to shut down 2 units: Unit 0 is OFF with credits: 3 Unit 1 is OFF with credits: 2 BUILD SUCCESSFUL (total time: 5 seconds) run: Enter the number of units: Enter the number of hours: In hour 1 we need to shut down 2 units: Unit 0 is OFF with credits: 1 Unit 1 is OFF with credits: 1 In hour 2 we need to shut down 0 units: Unit 0 is ON with credits: 1 Unit 1 is ON with credits: 1 In hour 3 we need to shut down 0 units: Unit 0 is ON with credits: 1 Unit 1 is ON with credits: 1 In hour 4 we need to shut down 1 units: Unit 0 is OFF with credits: 2 Unit 1 is ON with credits: 1 BUILD SUCCESSFUL (total time: 3 seconds)
ISIVI3230 In-class lab Module - Working with Arrays Spring 2020 FOCUS TOPICS • Arrays: storing multiple values of the same type Loops Random number generator TASK You are working for a utility company that provides electrical service to the local region. The company faces a serious problem: at times of high heat, high demand for electricity for air conditioning at times overwhelms available capacity, leading to power outages. To avoid this, the company has offered customers the option to have their air conditioner configured with remote control technology, and allow the company to shut down the A/C unit for an hour. In return, the customer receives a cost savings on the monthly bill for each hour the company turns off the A/C unit You have been asked to develop a prototype that: • For each demand hour: determines how many units need to be turned off, and tracks which units you have turned off Tracks credits for each hour an A/C unit is turned off, so that the corresponding customer can be credited at the end of the billing cycle The program should do the following: • Allow the user to enter the number of participating A/C units and the number of expected hours of peak demand Create and manage a set of data structures for keeping track of the status of A/C unit, and the number of credits earned for shut-off hours For each hour of peak demand: o Use random number generator to select the number of units the company needs to shut down to meet demand O Mark the status of turned-off units as "off" (note: for simplicity, always turn off units starting with unit 0 and going up) o Add a credit for each hour an A/C unit is shut down Print, for each hour of peak demand: o Number of unit-shutdowns needed to meet demand o The on/off status of each unit during the demand hour, and the total number of credits earned Ensure that each A/C unit is turned on at the end of each peak-demand hour • •

Similar Solved Questions

Cakery Bakery received $1,000 from a customer on August 5, 2016 for a wedding cake to be delivered on September 19, 2016. What would Cakery Bakery record on their books when the cake is successfully delivered?... 1 answer Zurich Company reports pretax financial income of$70,000 for 2017. The following item causes taxable income to be different than pretax financial income: Q10 10PTS Rent revenue on the tax return...
Zurich Company reports pretax financial income of $70,000 for 2017. The following item causes taxable income to be different than pretax financial income: Q10 10PTS Rent revenue on the tax return is greater than rent revenue recognized on the income statement by$22,000. Zurich's tax rate is 30%...