- 1

COVID 19 simulation

Hi EVERYONE, I WANT TO CREATE A COVID 19 SIMULATOR, I HAVE ATTACHED MY CODE BELOW, CAN ANY ONE SUGGEST ANY TIPS? https://code.sololearn.com/cN2t70n2wn4f/?ref=app

21st May 2020, 11:58 AM
Andy
4 ответов
+ 2
Ok, I just ran your program and drew the following conclusions about it: 1.) This program is going to simulate the number of people dying each day and the population remaining. 2.) It sets the initial population to 500 3) It uses an AWFUL algorithm to assign a random value to the infectionrate (line 21) 4.) The initial dots.........why? 5.) The results aren't clear. 6.) Population goes to negative! 7.) Decimals representing number of people dying!! Why? Sorry, but I have to be honest for helping you. So I would suggest you to: 1.) Clean up the code a bit and get rid of unnecessary dots. 2.) Choose a simple and effective algorithm for randomising the infectionrate. 3.) Make the loops efficient and understandable. 4.) Type cast the number of people infected and dead to int to ensure that no decimal is used to represent them. 5.) Assign the variables (like population) efficiently and MAKE USE OF THEM 😅 .....
21st May 2020, 2:38 PM
SSki11
SSki11 - avatar
+ 2
..... 6.) Use line breaks to separate the outputs of different days. 7.) Work on lines 25 and 29 (they're the same) Work on these suggestions and try to find such problems on your own too! The interpreter won't tell you about logical errors and it's all up to you to adopt good programming practices. Good luck!
21st May 2020, 2:40 PM
SSki11
SSki11 - avatar
+ 1
thanks!
21st May 2020, 3:54 PM
Andy