Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write awk.script that separately calculates how many European countries and Asia

ID: 3640602 • Letter: W

Question

Write awk.script that separately calculates how many European countries and Asian
countries are listed in the given file and what the total population is for Europe and Asia,
respectively.

The script also produces the following output:

Calculating statistics for file countries.txt…
Asia (2 countries): total population is 866
Europe (3 countries): total population is 172

Information in bold font was calculated based on the following countries.txt file:
Canada 3852 25 North
USA 3615 237 North
Brazil 3286 134 South
India 1267 746 Asia
Mexico 762 78 North
France 211 55 Europe
Japan 144 120 Asia
Germany 96 61 Europe
England 94 56 Europe

Explanation / Answer

PS: Please rate BEGIN{ print "Calculating statistic for file ",FILENAME} /Europe/ { eu_countries++; eu_pop+=$3; } /Asia/ { as_countries++; as_pop+=$3; } END { printf("Asia (%d countries):total population is %d ",as_countries,as_pop); printf("Europe (%d countries):total population is %d ",eu_countries,eu_pop); }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote