From d3207ced078eb894625f523e04261d32d526032c Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Thu, 7 Dec 2023 06:07:20 +0000 Subject: Wed, Dec 6, 2023, 10:07 PM -08:00 --- wk2/pset2/readability/readability.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'wk2/pset2/readability') diff --git a/wk2/pset2/readability/readability.c b/wk2/pset2/readability/readability.c index c04a66a..b65ab78 100644 --- a/wk2/pset2/readability/readability.c +++ b/wk2/pset2/readability/readability.c @@ -1,6 +1,6 @@ #include -#include #include +#include int main(void) { @@ -15,7 +15,7 @@ int main(void) c = text[i]; int j = c; i++; - //printf("%i ", j); + // printf("%i ", j); if (c == '.' || c == '!' || c == '?') { s++; @@ -30,14 +30,26 @@ int main(void) } } while (c != '\0'); - //printf("s: %f w: %f l: %f\n", s, w, l); - float L = (float)(l / w) * 100; - float S = (double)(s / w) * 100; + // printf("s: %f w: %f l: %f\n", s, w, l); + float L = (float) (l / w) * 100; + float S = (double) (s / w) * 100; float index = 0.0588 * L - 0.296 * S - 15.8; - //printf("L: %f, S: %f, Grade: %f\n", L, S, index); - if (index) + // printf("L: %f, S: %f, Grade: %f\n", L, S, index); + if (index < 1) + { + printf("Before Grade 1\n"); + } + else + { int ans = round(index); - printf("Grade: %i\n", ans); + if (ans >= 16) { + printf("Grade 16+\n"); + } + else + { + printf("Grade %i\n", ans); + } + } } /* -- cgit v1.2.3