## Day3: Let's write a simple application that converts words to into minutes by calculating an estimated time required to read manually.

Let's write a simple application that converts words into minutes by calculating an estimated time required to read manually.

The algorithm is as follows:

1. First, find the word count. Let's say it's 936 words.
2. Divide your total word count by 200. You'll get a decimal number, in this case, 4.69.
3. The first part of your decimal number is your minute. In this case, it is 4.
4. Take the second part of your decimal, the points which is 0.69, multiply that by 0.60. Those are your seconds. Round them up or down as necessary to get a whole second. In this case, 0.69*0.60 = 0.414. We will round that up to 41 seconds. The result? 938 words = a 4 minute, 41-second read. But that’s really specific. Why not round that time to make things simpler for your reader? Anything less than 30 seconds gets ignored; anything more than 30 seconds gets rounded up to the next minute. Ta-da! That rounding makes your 938-word article a 5-minute read.

15 Days of Code 6/26/2020 Unifiedcamp 2 Answer(s) 277 views

#### Author

Unifiedcamp 23

1. Calculating an estimated time to read a post in PHP.

```<?php

if (isset(\$_POST['submit']) && \$_POST['post'] != "") {
\$post = \$_POST['post'];
\$wordCount = str_word_count(strip_tags(\$post));

\$min = " minute";
}else{
\$min = " minutes";
}

}else{
}
?>
<!DOCTYPE html>
<html>
<body>
<form action="" method="post">
<input type="text" name="post">
<br>
<input type="submit" name="submit" value="Submit">
</form>
<?php echo \$timer;?>
</body>
</html>
```

Calculating an estimated time to read a post using JavaScript.

```<!DOCTYPE html>
<html>
<body>
<div>
</div>
<div>
</div>

<div>
</div>

<script type="text/javascript">
window.calcRT = ev => {
let time;

let postLength = ev.value.split(" ").length;
if(postLength > 0){
let value = Math.ceil(postLength / 200);
}
};
</script>
</body>
</html>
```

2. # A python program that calculates the time it takes to
#read words entered by the user
words = input("Write here: ")
count = 0

#count the number of words
for word in words:
count += 1

div = float(f"{(count / 200):,.2f}")
minutes = int(div)
sec = int(((div - minutes) * .60) * 100)#calculates for the seconds

if sec <= 30: