CrazyEngineers
  • Unix awk script

    Learnerabc

    Member

    Updated: Oct 24, 2024
    Views: 972
    Hi, I am stuck on this problem if anyone can help

    Write awk.script that calculates which continent (Europe, Asia or America) has the largest population density based on the given input. America corresponds to two areas in the file, North and South. The script also produces the following output:


    [FONT=Courier New, monospace]Based on [/FONT][FONT=Courier New, monospace]countries.txt[/FONT][FONT=Courier New, monospace],[/FONT][FONT=Courier New, monospace][/FONT][FONT=Courier New, monospace]continent with the largest population density is[/FONT]


    [FONT=Courier New, monospace]Asia[/FONT][FONT=Courier New, monospace]: population density = [/FONT][FONT=Courier New, monospace]866[/FONT][FONT=Courier New, monospace]/[/FONT][FONT=Courier New, monospace]1411 [/FONT][FONT=Courier New, monospace]=[/FONT][FONT=Courier New, monospace] 0.6137[/FONT]


    Information in blue color was calculated based on the following countries.txt file (format is
    country square population area):
    [FONT=Courier New, monospace]Canada 3852 25 North[/FONT]
    [FONT=Courier New, monospace]USA 3615 237 North[/FONT]
    [FONT=Courier New, monospace]Brazil 3286 134 South[/FONT]
    [FONT=Courier New, monospace]India 1267 746 Asia[/FONT]
    [FONT=Courier New, monospace]Mexico 762 78 North[/FONT]
    [FONT=Courier New, monospace]France 211 55 Europe[/FONT]
    [FONT=Courier New, monospace]Japan 144 120 Asia[/FONT]
    [FONT=Courier New, monospace]Germany 96 61 Europe[/FONT]
    [FONT=Courier New, monospace]England 94 56 Europe[/FONT]
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • MaRo

    MemberFeb 19, 2010

    What's your question?

    If it's your homework no one will make it to you!
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register