Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# Arrays Need to wrote a code with following requirnments. Need to write a code(array) following requiremnets on the pictures. It should looks like last

C# Arrays
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Need to wrote a code with following requirnments.
Need to write a code(array) following requiremnets on the pictures. It should looks like last pictures(Example output)
Plan of Attack 1. For each of the two assignments, create an individual VS solution. 2. Make sure you understand what is required for this assignment! This is just like the real world: if there is ambiguity, it's up to you to resolve it. Review the materials carefully and ask clarifying questions when needed. 3. Plan and estimate your work, but this assignment does not require you to submit a time sheet with your solution. 4. Build pseudocode or a flowchart to help you work out the logic. 5. Write down a set of test cases that will help you to ferret out logic problems and ensure that your code is working 6. Code, test and debug using your test cases. And remember: Do not use goto, break (except in a switch statement) or continue. Do not use return or Environment.Exito Do not use variables of type var. . Do not include any commented-out code in your submission Remove all unnecessary using statements. General requirements for each simulation: The program must behave as described in the spec. The program must execute without any exceptions (ie., run-time errors). . There must be no warnings. The code must conform to the course Software Development Standards in all other respects, including comments. Numeric values must be right-justified and appropriately formatted. Happy coding! Specifications start on the next page. 2. Homework 4.2 - Woodchuck wood chucking simulation (40 of 60 points) The Whistlepig Association of America has hired ACME industries to develop a simulation to answer, once and for all this burning question: how much wood would a woodchuck chuck if a woodchuck could chuck wood? The simulator will produce a two-dimensional matrix. Each column represents one day of chucking wood. Each row represents one woodchuck. Each cell in the matrix, then, holds the number of pieces of wood chucked by an individual woodchuck on a specific day. The simulator is to work as follows: Display a nice banner explaining the simulation in brief. . Ask the user how many woodchucks to simulate (1 to 100). Ask the user how many days to simulate (1 - 10). Using the random number generator in the Random class, populate each cell with a value between 1 and 50 (inclusive) that represents the number of pieces of wood chucked by the specific woodchuck on that specific day. Print the matrix. Each row will be labeled with a woodchuck designator: a number between 1 and the number of woodchucks in the simulation. Each column will be labeled with a number representing the day of the simulation Then print: The total number of pieces of wood chucked across the simulation, and The average number of pieces of wood chucked per day per woodchuck... o in nicely formatted messages. How much wood would 1 Chuck? I just don't know 6 For full credit. Submit your program as a .cs file named Woodchuck. Mine would be "MiniumWoodchuck.cs" Required coding features and hints Use constants for the maximum number of woodchucks and the maximum number of days. Ensure that the user types in positive whole numbers for number of woodchucks and number of days using TryParse and a validation loop. Use the Random class to calculate the integer value of each cell. Use at least one foreach. Hint: you might want to use foreach to total all the values in the array Use a two-dimensional array to represent how much wood a woodchuck chucks each day. Output formatting: Each woodchuck has a numeric designation from one to the number of woodchucks in the simulation. Use the woodchuck's number as the basis for the index. Note that you'll need to adjust the index because the first element of an array is in position 0. o Print the woodchuck's designation at the beginning of each row. The average amount of wood chucked per woodchuck must be a float with two decimal places. Make sure the result includes fractional values. Add horizontal and vertical lines to separate headings and woodchuck designators from the matrix Challenge yourself. Bonus features for Homework 4.2 1. At the end of each simulation, ask the user whether they would like to run another simulation. If they do, start back at the top asking how many woodchucks, days, etc. Each simulation is numbered; print the number of the simulation as a heading for each iteration. Note: don't forget to reset the array! 2. Add a total column and a total row that sums the value of each row and column. That is, each row total shows the output of a woodchuck for all days in the simulation, and each column total shows the output of all woodchucks for one day of the simulation 3. Add an average column and an average row that shows the average wood chucked per woodchuck across all the days in the simulation (in each row) and the average wood chucked by all woodchucks for a single day (in each column). Each row and column average must include one decimal point of precision. Make sure each one is a fractional value. 4. If you do 2, 3 or both, add vertical and horizontal lines to visually distinguish matrix detail from the total and average 7 Sample output for Homework 4.2 - full credit In the example interaction below, data typed by the user appears highlighted and in boldface. ACME Industries Rodent Sciences Division WOODCHUCK WOOD CHUCKING SIMULATION V. 2.0 One row per woodchuck, one column per day Enter number of woodchucks for this simulation (1-100): 12 Enter number of days for this simulation (1-10): 10 1 2 3 5 8 9 le 48 29 11 31 1 27 11 21 31 4 5 6 71 81 91 101 24 43 1e 15 40 26 19 5 34 44 31 41 7 15 23 9 35 8 11 42 34 49 s 11 6 41 29 8 44 14 24 47 6 23 8 37 21 32 4 15 32 19 22 47 12 5 4 8 12 19 8 37 21 26 17 39 30 14 5 46 34 18 35 28 24 4 8 16 Se 47 42 43 35 8 16 3 22 43 16 35 46 34 39 Total wood chucked: Average woodchuck chuckage: 2,456 24.56 Press any key to wrap it up... Sample output for Homework 4.2 with bonus features In the example interaction below, data typed by the user appears highlighted and in boldface. ACME Industries Rodent Sciences Division WOOOCHUCK WOOD OUCKING SIMULATION V. 1.1 One row per woodchuck, one column per day Includes Bonus Features!! Enter number of woodchucks for this simulation (1-100): 10 Enter nunber of days for this simulation (1-10): SIMULATION 1: 10 woodchucks over 5 days 1 2 3 Avg Tot 47 13 15 12 34 14 32 29 48 $ 48 32 42 33 11 21 31 41 51 61 71 81 91 101 3 43 2 B 12 30 23 38 36 se 29.4 41 1 23.4 2 19.2 26 29. 12 27.8 34 27.6 491 27.6 19131.0 12 26.6 2 1 18.0 147 117 96 145 139 138 138 155 133 90 5e 5 8 48 21 36 45 24 Avg Tot 1 27.5 25.6 20.9 31.1 24.7 275 256 209 311 247 Total wood chucked: 1,298 Average woodchuck chuckage: 25.96 To run another simulation, typer: Enter number of woodchucks for this simulation (1-100): 5 Enter number of days for this simulation (1-10): SIMULATION 2: 5 woodchucks over 7 days 1 2 3 4 5 6 7 Avg Tot 11 21 31 51 45 15 44 22 38 24 22 | 28.9 202 11 35 12 41 35 32 20 26.6 185 34 5 9 2 5 5 15.7 110 42 4 13 5 23 14.3 100 31 27 33 11 48 20 4 1 28.6 200 32.6 17.2 22.2 16.2 34.4 15.0 22.0 163 86 111 81 172 75 110 Avg! Tot Total wood chucked: 798 Average woodchuck chuckage: 22.80 To run another simulation, type "Y":n Press any key to end program... 9 Plan of Attack 1. For each of the two assignments, create an individual VS solution. 2. Make sure you understand what is required for this assignment! This is just like the real world: if there is ambiguity, it's up to you to resolve it. Review the materials carefully and ask clarifying questions when needed. 3. Plan and estimate your work, but this assignment does not require you to submit a time sheet with your solution. 4. Build pseudocode or a flowchart to help you work out the logic. 5. Write down a set of test cases that will help you to ferret out logic problems and ensure that your code is working 6. Code, test and debug using your test cases. And remember: Do not use goto, break (except in a switch statement) or continue. Do not use return or Environment.Exito Do not use variables of type var. . Do not include any commented-out code in your submission Remove all unnecessary using statements. General requirements for each simulation: The program must behave as described in the spec. The program must execute without any exceptions (ie., run-time errors). . There must be no warnings. The code must conform to the course Software Development Standards in all other respects, including comments. Numeric values must be right-justified and appropriately formatted. Happy coding! Specifications start on the next page. 2. Homework 4.2 - Woodchuck wood chucking simulation (40 of 60 points) The Whistlepig Association of America has hired ACME industries to develop a simulation to answer, once and for all this burning question: how much wood would a woodchuck chuck if a woodchuck could chuck wood? The simulator will produce a two-dimensional matrix. Each column represents one day of chucking wood. Each row represents one woodchuck. Each cell in the matrix, then, holds the number of pieces of wood chucked by an individual woodchuck on a specific day. The simulator is to work as follows: Display a nice banner explaining the simulation in brief. . Ask the user how many woodchucks to simulate (1 to 100). Ask the user how many days to simulate (1 - 10). Using the random number generator in the Random class, populate each cell with a value between 1 and 50 (inclusive) that represents the number of pieces of wood chucked by the specific woodchuck on that specific day. Print the matrix. Each row will be labeled with a woodchuck designator: a number between 1 and the number of woodchucks in the simulation. Each column will be labeled with a number representing the day of the simulation Then print: The total number of pieces of wood chucked across the simulation, and The average number of pieces of wood chucked per day per woodchuck... o in nicely formatted messages. How much wood would 1 Chuck? I just don't know 6 For full credit. Submit your program as a .cs file named Woodchuck. Mine would be "MiniumWoodchuck.cs" Required coding features and hints Use constants for the maximum number of woodchucks and the maximum number of days. Ensure that the user types in positive whole numbers for number of woodchucks and number of days using TryParse and a validation loop. Use the Random class to calculate the integer value of each cell. Use at least one foreach. Hint: you might want to use foreach to total all the values in the array Use a two-dimensional array to represent how much wood a woodchuck chucks each day. Output formatting: Each woodchuck has a numeric designation from one to the number of woodchucks in the simulation. Use the woodchuck's number as the basis for the index. Note that you'll need to adjust the index because the first element of an array is in position 0. o Print the woodchuck's designation at the beginning of each row. The average amount of wood chucked per woodchuck must be a float with two decimal places. Make sure the result includes fractional values. Add horizontal and vertical lines to separate headings and woodchuck designators from the matrix Challenge yourself. Bonus features for Homework 4.2 1. At the end of each simulation, ask the user whether they would like to run another simulation. If they do, start back at the top asking how many woodchucks, days, etc. Each simulation is numbered; print the number of the simulation as a heading for each iteration. Note: don't forget to reset the array! 2. Add a total column and a total row that sums the value of each row and column. That is, each row total shows the output of a woodchuck for all days in the simulation, and each column total shows the output of all woodchucks for one day of the simulation 3. Add an average column and an average row that shows the average wood chucked per woodchuck across all the days in the simulation (in each row) and the average wood chucked by all woodchucks for a single day (in each column). Each row and column average must include one decimal point of precision. Make sure each one is a fractional value. 4. If you do 2, 3 or both, add vertical and horizontal lines to visually distinguish matrix detail from the total and average 7 Sample output for Homework 4.2 - full credit In the example interaction below, data typed by the user appears highlighted and in boldface. ACME Industries Rodent Sciences Division WOODCHUCK WOOD CHUCKING SIMULATION V. 2.0 One row per woodchuck, one column per day Enter number of woodchucks for this simulation (1-100): 12 Enter number of days for this simulation (1-10): 10 1 2 3 5 8 9 le 48 29 11 31 1 27 11 21 31 4 5 6 71 81 91 101 24 43 1e 15 40 26 19 5 34 44 31 41 7 15 23 9 35 8 11 42 34 49 s 11 6 41 29 8 44 14 24 47 6 23 8 37 21 32 4 15 32 19 22 47 12 5 4 8 12 19 8 37 21 26 17 39 30 14 5 46 34 18 35 28 24 4 8 16 Se 47 42 43 35 8 16 3 22 43 16 35 46 34 39 Total wood chucked: Average woodchuck chuckage: 2,456 24.56 Press any key to wrap it up... Sample output for Homework 4.2 with bonus features In the example interaction below, data typed by the user appears highlighted and in boldface. ACME Industries Rodent Sciences Division WOOOCHUCK WOOD OUCKING SIMULATION V. 1.1 One row per woodchuck, one column per day Includes Bonus Features!! Enter number of woodchucks for this simulation (1-100): 10 Enter nunber of days for this simulation (1-10): SIMULATION 1: 10 woodchucks over 5 days 1 2 3 Avg Tot 47 13 15 12 34 14 32 29 48 $ 48 32 42 33 11 21 31 41 51 61 71 81 91 101 3 43 2 B 12 30 23 38 36 se 29.4 41 1 23.4 2 19.2 26 29. 12 27.8 34 27.6 491 27.6 19131.0 12 26.6 2 1 18.0 147 117 96 145 139 138 138 155 133 90 5e 5 8 48 21 36 45 24 Avg Tot 1 27.5 25.6 20.9 31.1 24.7 275 256 209 311 247 Total wood chucked: 1,298 Average woodchuck chuckage: 25.96 To run another simulation, typer: Enter number of woodchucks for this simulation (1-100): 5 Enter number of days for this simulation (1-10): SIMULATION 2: 5 woodchucks over 7 days 1 2 3 4 5 6 7 Avg Tot 11 21 31 51 45 15 44 22 38 24 22 | 28.9 202 11 35 12 41 35 32 20 26.6 185 34 5 9 2 5 5 15.7 110 42 4 13 5 23 14.3 100 31 27 33 11 48 20 4 1 28.6 200 32.6 17.2 22.2 16.2 34.4 15.0 22.0 163 86 111 81 172 75 110 Avg! Tot Total wood chucked: 798 Average woodchuck chuckage: 22.80 To run another simulation, type "Y":n Press any key to end program... 9

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions