TASK You are working for a utility company that provides electrical service to the local region....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 more sophisticated prototype than the task presented in Lab 6: For each demand hour: determine how many units need to be turned off, and track which units you have turned off In the hour Track 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 in each hour, and the number of total credits earned by a unit for shut-off hours For each hour of peak demand: O O Use random number generator to select the number of units the company needs to shut down to meet demand O Randomly select the units to be turned off, and mark the status of turned-off units as "off", ensuring that you only turn off those units that are still on Add a credit for each hour an A/C unit is shut down O Print, for each hour of peak demand: The number of unit-shutdowns needed to meet demand The on/off status (recorded as 1/0) of each unit during the demand hour O Print the total credits earned by each A/C unit USEFUL CODE AND HINTS FOR THIS TASK ● ● The Random class will generate random numbers. Declare a variable of the Random class in the same way you declare a Scanner variable: Random ranVariable = new Random(); (and include an import for java.util.Random) Get a random integer using the nextInt(int upperLimit) method. ■ The nextInt method generates an integer in the range from 0 up to (but not including) the upperLimit value To get another random number, simply use the ranVariable's nextInt method again, there is no need to create another Random class variable O O O Use the examples in the book and slides to help you with syntax for nesting for loops and array access (assigning values to and retrieving values from array elements). Be careful when choosing the value or variable you put in the square brackets [] for accessing array elements. Think carefully when you make these choices! INSTRUCTIONS 1. Prompt the user for the number of participating units and expected peak demand hours 2. Create two class-level named constant integers, called ON and OFF. ON should have a value of 1, and OFF should have a value of 0. 3. Create two arrays: O A two-dimensional integer array called unitStatus, with a number of rows equal to the number of peak demand hours, and a number of columns equal to the number of participating units O A one-dimensional integer array called unitCredit, with an array element count equal to the number of participating units 4. Initialize the arrays: O Set each element of the unitStatus array to ON Set each element of the unitCredit array to 0 O 5. For each demand hour: O O oo o O 6. Next, document what happened during the demand hour, following the format shown in the sample output O Print a header for the hour showing the hour number and number of units to be turned off O To determine how many units to shut down, generate a random integer between 0 and the total number of A/C units, and store it in a variable HINT: Be sure that your code allows for 0 units to be needed, as well as the maximum number of units available. O To determine which unit(s) to shut down, generate a series of random integers between O and the one less than the total number of A/C units, this will be the index of the AC unit to turn off. If you find an ON A/C unit corresponding to the random index number, turn it OFF, and increment the credit count If you find an OFF A/C unit corresponding to the random index number, do nothing to the unit and try again with another random index THINK: You will need to keep generating random numbers until you find a sufficient number of units to turn off. You can't pre-determine how many times you will need to generate numbers to fulfill this need, so this cannot be written with a for loop. What other options do you have? 7. Make sure that your output matches the sample output in wording, capitalization, punctuation, and spacing. Print the status of all units in one row as 0 or 1 as shown in the sample output Indent the status line by five spaces, so that the hour header lines are clearly distinct from the unit-status lines 8. Do sufficient testing of your code to ensure that: O you are able to turn off all units (try with a small number of units and many hours) given the number of units to shut down, you actually do shut down that many units you are able to shut down the first as well as the last unit (test with a small number of units and many hours) your credits for a unit match the number of times that unit was shut down SAMPLE OUTPUT Note: your computed output will vary due to the use of random numbers run: Enter the number of units: 3 Enter the number of hours: 5 HØ: turn off 0 units 1 1 1 H1: turn off 2 units 001 H2: turn off 3 units 0 0 0 H3: turn off 2 units 001 H4: turn off 1 units 101 Unit earned 3 credits Unit 1 earned 4 credits Unit 2 earned 1 credits BUILD SUCCESSFUL (total time: 1 second) run: Enter the number of units: 5 Enter the number of hours: 3 HØ: turn off 2 units 1 1 0 0 1 H1: turn off 2 units 1 1 0 0 1 H2: turn off 4 units 0 1 0 0 0 Unit earned 1 credits Unit 1 earned 0 credits Unit 2 earned 3 credits Unit 3 earned 3 credits Unit 4 earned 1 credits BUILD SUCCESSFUL (total time: 3 seconds) 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 more sophisticated prototype than the task presented in Lab 6: For each demand hour: determine how many units need to be turned off, and track which units you have turned off In the hour Track 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 in each hour, and the number of total credits earned by a unit for shut-off hours For each hour of peak demand: O O Use random number generator to select the number of units the company needs to shut down to meet demand O Randomly select the units to be turned off, and mark the status of turned-off units as "off", ensuring that you only turn off those units that are still on Add a credit for each hour an A/C unit is shut down O Print, for each hour of peak demand: The number of unit-shutdowns needed to meet demand The on/off status (recorded as 1/0) of each unit during the demand hour O Print the total credits earned by each A/C unit USEFUL CODE AND HINTS FOR THIS TASK ● ● The Random class will generate random numbers. Declare a variable of the Random class in the same way you declare a Scanner variable: Random ranVariable = new Random(); (and include an import for java.util.Random) Get a random integer using the nextInt(int upperLimit) method. ■ The nextInt method generates an integer in the range from 0 up to (but not including) the upperLimit value To get another random number, simply use the ranVariable's nextInt method again, there is no need to create another Random class variable O O O Use the examples in the book and slides to help you with syntax for nesting for loops and array access (assigning values to and retrieving values from array elements). Be careful when choosing the value or variable you put in the square brackets [] for accessing array elements. Think carefully when you make these choices! INSTRUCTIONS 1. Prompt the user for the number of participating units and expected peak demand hours 2. Create two class-level named constant integers, called ON and OFF. ON should have a value of 1, and OFF should have a value of 0. 3. Create two arrays: O A two-dimensional integer array called unitStatus, with a number of rows equal to the number of peak demand hours, and a number of columns equal to the number of participating units O A one-dimensional integer array called unitCredit, with an array element count equal to the number of participating units 4. Initialize the arrays: O Set each element of the unitStatus array to ON Set each element of the unitCredit array to 0 O 5. For each demand hour: O O oo o O 6. Next, document what happened during the demand hour, following the format shown in the sample output O Print a header for the hour showing the hour number and number of units to be turned off O To determine how many units to shut down, generate a random integer between 0 and the total number of A/C units, and store it in a variable HINT: Be sure that your code allows for 0 units to be needed, as well as the maximum number of units available. O To determine which unit(s) to shut down, generate a series of random integers between O and the one less than the total number of A/C units, this will be the index of the AC unit to turn off. If you find an ON A/C unit corresponding to the random index number, turn it OFF, and increment the credit count If you find an OFF A/C unit corresponding to the random index number, do nothing to the unit and try again with another random index THINK: You will need to keep generating random numbers until you find a sufficient number of units to turn off. You can't pre-determine how many times you will need to generate numbers to fulfill this need, so this cannot be written with a for loop. What other options do you have? 7. Make sure that your output matches the sample output in wording, capitalization, punctuation, and spacing. Print the status of all units in one row as 0 or 1 as shown in the sample output Indent the status line by five spaces, so that the hour header lines are clearly distinct from the unit-status lines 8. Do sufficient testing of your code to ensure that: O you are able to turn off all units (try with a small number of units and many hours) given the number of units to shut down, you actually do shut down that many units you are able to shut down the first as well as the last unit (test with a small number of units and many hours) your credits for a unit match the number of times that unit was shut down SAMPLE OUTPUT Note: your computed output will vary due to the use of random numbers run: Enter the number of units: 3 Enter the number of hours: 5 HØ: turn off 0 units 1 1 1 H1: turn off 2 units 001 H2: turn off 3 units 0 0 0 H3: turn off 2 units 001 H4: turn off 1 units 101 Unit earned 3 credits Unit 1 earned 4 credits Unit 2 earned 1 credits BUILD SUCCESSFUL (total time: 1 second) run: Enter the number of units: 5 Enter the number of hours: 3 HØ: turn off 2 units 1 1 0 0 1 H1: turn off 2 units 1 1 0 0 1 H2: turn off 4 units 0 1 0 0 0 Unit earned 1 credits Unit 1 earned 0 credits Unit 2 earned 3 credits Unit 3 earned 3 credits Unit 4 earned 1 credits BUILD SUCCESSFUL (total time: 3 seconds)
Expert Answer:
Answer rating: 100% (QA)
Java code import javautilRandom import javautilScanner public class Credits public static void mainS... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Assume that a trader in HSBS has bought EUR 10,000,000 on Feb 03, 2020. Estimate one day VAR with a 95% confidence interval for the FX position with the Historical Simulation approach. Compose some...
-
Livingston had worked for Merrill Lynch for 20 years as a securities sales representative (account executive). In January 1972, he and 47 other account executives were given the honorary title of...
-
Write the function in the form y = (u) and u = g(x). Then find dy/dx as a function of x. y = (4 - 3x) 9
-
Explain several implications of IFRS on financial reporting by health care organizations.
-
As the production planner for Scott Sampson Products, Inc., you have been given a bill of material for a bracket that is made up of a base, two springs, and four clamps. The base is assembled from...
-
Briefly list the major administration tasks you can handle to manage a database in cloud. . QUESTION 12 List the major components of email system. QUESTION 13 In a job interview, you are...
-
A bank categorizes its customers into one of three groups based on their banking habits. A random sample of 30 customers from each group was selected, and the number of times each customer visited...
-
As any historian, sociologist, or anthropologist could tell you, different cultures, religious groups, and subcultures often have different views about ethical matters: Different societies have...
-
If the total cost of producing three units of output is $2,621 and the total cost of producing four units of output is $3,109 then the marginal cost of the fourth unit is $? Please enter your...
-
Using the following circuit, what should be the value of B (B3B2B1Bo) where Co=0 to compute A-5? B3 A3 B A B A1 Bo Ao FA C3 C FA FA 0 C Co FA C4 $3 $2 S So B =
-
A firms production function is given by Q = 2K 2 + 6L. Does this production function exhibit constant returns to scale?
-
Q 2. What are the advantages and disadvantages of Sole Proprietorship ? Detailed information and discussion is necessary.
-
You choose your portfolio following the advice of the modern portfolio theory. Suppose you had $100000 in cash and you borrowed another $26861 from the bank at the annual risk-free rate of 2%. You...
-
In order to stretch your calf muscles you need to: Select one: a. a plantar flex at the ankle b. dorsiflex at the ankle c. flex at the knee d. extend at the knee e. none of the above
-
For the following exercises, write the first four terms of the sequence. a n = 2 n 2
-
You are working for a consulting firm that provides risk-management products for clients. Your task is to provide your company's sales force with information on prospective clients. Assume that...
-
Refer to Exhibit 6-1 and using the information provided, can you determine the cross spot rate (i.e., a rate computed from two other exchange rates) between the euro and the British pound? EXHIBIT...
-
What are the information needs of four user groups that rely on foreign financial statements for their financial decisions? Are the four main steps in financial statement analysis equally important...
-
Which mechanism of bacterial genetic transfer does not require recombination with the bacterial chromosome?
-
Explain why small deletions and duplications are less likely than large ones to have a detrimental effect on an individuals phenotype. If a small deletion within a single chromosome happens to have a...
-
Explain why inversions and reciprocal translocations do not usually cause a phenotypic effect. Then explain how they can do so in certain cases.
Study smarter with the SolutionInn App