Jump to content

4 posts in this topic

Recommended Posts

Posted

 

//This program allows the user to search through files from the Social //Security Administraction which contain data on various names. //If found, it then graphs the popularity of each name over time. //Constant values can be used to alter the program's starting year //and the display of the graph itself. import java.util.*; import java.awt.*; import java.io.*; public class BabyNames { public static final int STARTING_DECADE = 1890; //will be initial decade public static final int WIDTH = 60; //width of decade bars on graph public static final int HEIGHT = 30; //height of grey rectangles on graph //This method assigns the return of an indtroductory method to a String and //then passes that string into another method. public static void main(String[] args) throws FileNotFoundException { String name = introName(); conditional(name); } //prints a description of the program, then invites the user to input a name. //Returns the inputted name to main. public static String introName() { System.out.println("This program allows you to search through the"); System.out.println("data from the Social Security Administration"); System.out.println("to see how popular a particular name has been"); System.out.println("since " + STARTING_DECADE + "."); System.out.println(); System.out.print("Name: "); Scanner console = new Scanner(System.in); String name = (console.next()); return name; } //This method evaluates whether or not the inputted name is valid by passing it into //a search method to scan the text files. If the name is valid, this method will call the //graphics methods to construct the graph. If not valid, the method will give a "not found" //reply. The parameter passed is the inputted name. public static void conditional(String name) throws FileNotFoundException { Scanner names = new Scanner(new File("names.txt")); String stats = search(names, name); if (stats.length() > 0) { Scanner meanings = new Scanner(new File("meanings.txt")); String meaning = search(meanings, name); if (meaning.length() > 0) { DrawingPanel graph = new DrawingPanel(780, 560); Graphics g = graph.getGraphics(); graphTemplate(g); graphMeaning(g, meaning); graphDates(g, stats); } } else { System.out.print("\"" + name + "\"" + " not found."); } } //used as a method to search text files for the inputted name. Accepts a Scanner assigned //to a certain .text document, and the user inputted name. public static String search(Scanner namesList, String name) throws FileNotFoundException { while(namesList.hasNextLine()) { String nameLC = name.toLowerCase(); String line = namesList.nextLine(); String lineLC = line.toLowerCase(); if(lineLC.indexOf(nameLC) == 0 && lineLC.charAt(nameLC.length()) == ' ') { System.out.println(line); return line; } } return ""; } //prints the fixed background graphics for the graph. Accepts graphics as parameter. public static void graphTemplate(Graphics g) { g.setColor(Color.LIGHT_GRAY); g.fillRect(0, 0, 780, 0 + HEIGHT); g.fillRect(0, 560 - HEIGHT, 780, 560); g.setColor(Color.BLACK); g.drawLine(0, HEIGHT, 780, HEIGHT); g.drawLine(0, 560 - HEIGHT, 780, 560 - HEIGHT); g.drawRect(0, 0, 779, 559); } //prints the meaning of the name at the header of the graph (top grey rectangle). Accepts //graphics and the string for the meaning of the name as parameters public static void graphMeaning(Graphics g, String meaning) throws FileNotFoundException { g.setColor(Color.BLACK); g.drawString(" " + meaning, 0, 16); } //prints the dates on the graph, their corresponding population values, //and fills in the bars on the graph, the color corresponding to each gender. //Accepts graphics and the string of dates as parameters. public static void graphDates(Graphics g, String stats) throws FileNotFoundException { String gender = stats.substring((stats.indexOf(" ") + 1), (stats.indexOf(" ") + 3)); String dates = stats.substring(stats.indexOf(" ") + 3); Scanner dates2 = new Scanner(dates); int yearCount = 0; while(dates2.hasNextInt()) { int n = dates2.nextInt(); g.setColor(Color.BLACK); g.drawString(" " + (STARTING_DECADE + yearCount * 10), yearCount * WIDTH, 552); if (n == 0) { g.drawString(" " + 0, yearCount * WIDTH, 560 - HEIGHT); } else { g.drawString(" " + n, yearCount * WIDTH, ((n % 2) + (n / 2) + HEIGHT)); g.setColor(Color.PINK); if (gender.charAt(0) == 'm'){ g.setColor(Color.BLUE); } g.fillRect(yearCount * WIDTH, ((n % 2) + (n / 2) + HEIGHT), WIDTH / 2, 560 - ((n % 2) + (n / 2) + HEIGHT) - HEIGHT); } yearCount++; } } }

 

Posted (edited)

what does it do?

It says what it does in the code:

//This program allows the user to search through files from the Social //Security Administraction which contain data on various names. //If found, it then graphs the popularity of each name over time. //Constant values can be used to alter the program's starting year //and the display of the graph itself. 
Updated by Goggwell

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Our picks

    • NETHER DUNGEONS v1.18 [+3 Cheats]
      Modded/Hacked App: NETHER DUNGEONS By ARAKUMA STUDIO S.A.
      Bundle ID: com.ArakumaStudio.NetherDungeons
      iTunes Store Link: https://apps.apple.com/us/app/nether-dungeons/id6737908225?uo=4



      🤩 Hack Features

      - Never Die
      - Activate Vip Mode
      - Add Currency
       
        • Like
      • 4 replies
    • NETHER DUNGEONS v1.18 [+3 Jailed Cheats]
      Modded/Hacked App: NETHER DUNGEONS By ARAKUMA STUDIO S.A.
      Bundle ID: com.ArakumaStudio.NetherDungeons
      iTunes Store Link: https://apps.apple.com/us/app/nether-dungeons/id6737908225?uo=4

       

      🤩 Hack Features

      - Never Die
      - Activate Vip Mode
      - Add Currency
        • Like
      • 3 replies
    • Kiwoyong: Raise Your Dragon ( 키워용: 도굴라이프 ) v1.5.16 +2 Cheats [ Damage ]
      Modded/Hacked App: 키워용: 도굴라이프 By Co., Ltd. NGELGAMES
      Bundle ID: kr.ngelgames.dragon
      App Store Link: https://apps.apple.com/kr/app/%ED%82%A4%EC%9B%8C%EC%9A%A9-%EB%8F%84%EA%B5%B4%EB%9D%BC%EC%9D%B4%ED%94%84/id6618145893?uo=4

       
       

      🤩 Hack Features

      - God Mode
      - Damage Multiplier
        • Thanks
      • 1 reply
    • Hungry Shark World v6.7.7 +5 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Hungry Shark World By Ubisoft
      Bundle ID: com.ubisoft.hungrysharkworld
      iTunes Store Link: https://apps.apple.com/us/app/hungry-shark-world/id1046846443?uo=4


      Mod Requirements:
      - Non-Jailbroken/Jailed or Jailbroken iPhone/iPad/iPod Touch.
      - Sideloadly / Cydia Impactor or alternatives.
      - A Computer Running Windows/macOS/Linux with iTunes installed.


      Hack Features:
      - Unlimited Coins
      - Unlimited Gems
      - Unlimited Pearls
      - Unlimited Boost
      - Season Pass Unlocked


      Jailbreak required hack(s): [Mod Menu Hack] Hungry Shark World v5.9.1 +5 Cheats [ Unlimited Currencies ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 227 replies
    • Hungry Shark World v6.7.7 +5 Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Hungry Shark World By Ubisoft
      Bundle ID: com.ubisoft.hungrysharkworld
      iTunes Store Link: https://apps.apple.com/us/app/hungry-shark-world/id1046846443?uo=4


      Hack Features:
      - Unlimited Coins
      - Unlimited Gems
      - Unlimited Pearls
      - Unlimited Boost
      - Season Pass Unlocked


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Hungry Shark World v5.9.1 +4 Jailed Cheats [ Unlimited Currencies ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 92 replies
    • Run! Goddess v1.0.10 [+3 Jailed Cheats]
      Modded/Hacked App: Run! Goddess By TOP GAMES INC.
      Bundle ID: com.topgamesinc.rg
      iTunes Store Link: https://apps.apple.com/us/app/run-goddess/id6667111749?uo=4



      🤩 Hack Features

      - No Skill Cooldown
      - Slow Enemy
      - Enemy Can't Attack (Enemy Can't Do Damage)
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 31 replies
    • Run! Goddess v1.0.10 [+3 Cheats]
      Modded/Hacked App: Run! Goddess By TOP GAMES INC.
      Bundle ID: com.topgamesinc.rg
      iTunes Store Link: https://apps.apple.com/us/app/run-goddess/id6667111749?uo=4

       

      🤩 Hack Features

      - No Skill Cooldown
      - Slow Enemy
      - Enemy Can't Attack (Enemy Can't Do Damage)
       
        • Informative
        • Agree
        • Thanks
        • Winner
        • Like
      • 24 replies
    • Sword Master Story Cheats v4.107.556 +5
      Modded/Hacked App: Sword Master Story By SuperPlanet corp.
      Bundle ID: com.superplanet.swordmaster
      iTunes Store Link: https://apps.apple.com/us/app/sword-master-story/id1521447065?uo=4


      Hack Features:
      - Custom Player Stats
      - Weak Enemies
      - One Hit Kill
      - & More

      Press & Hold to read feature description


      iOS Hack Download Link: https://iosgods.com/topic/146819-sword-master-story-cheats-v42294-3/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 1,445 replies
    • Subway Surfers v3.45.0 +22 Jailed Cheats [ Currencies + More ]
      Modded/Hacked App: Subway Surfers By Sybo Games ApS
      Bundle ID: com.kiloo.subwaysurfers
      iTunes Store Link: https://apps.apple.com/us/app/subway-surfers/id512939461?uo=4


      Hack Features:
      - Unlimited Currencies
      - Freeze Currencies
      - Free In-App Purchases
      - All Characters Unlocked
      - All Boards Unlocked
      - God Mode
      - No Stumble
      - Score Multiplier
      - Speed Multiplier
      - Gravity Multiplier
      - Jump Height Multiplier
      - Air Jump Height Multiplier
      - Unlimited Jumps
      - Unlimited Powers
      - Instant Lane Change
      - Freeze Trains
      - No Clip
      - Disable All Pickup
      - No Revive Cost
      - Unlimited Jetpack Time
      - Camera Stops
      - Camera Follows


      Jailbreak required hack(s): [Mod Menu Hack] Subway Surfers v3.40.0 +20 Cheats [ Currencies + More ] - ViP Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 35 replies
    • Subway Surfers v3.45.0 +22 Cheats [ Currencies + More ]
      Modded/Hacked App: Subway Surfers By Sybo Games ApS
      Bundle ID: com.kiloo.subwaysurfers
      iTunes Store Link: https://apps.apple.com/us/app/subway-surfers/id512939461?uo=4


      Hack Features:
      - Unlimited Currencies
      - Freeze Currencies
      - Free In-App Purchases
      - All Characters Unlocked
      - All Boards Unlocked
      - God Mode
      - No Stumble
      - Score Multiplier
      - Speed Multiplier
      - Gravity Multiplier
      - Jump Height Multiplier
      - Air Jump Height Multiplier
      - Unlimited Jumps
      - Unlimited Powers
      - Instant Lane Change
      - Freeze Trains
      - No Clip
      - Disable All Pickup
      - No Revive Cost
      - Unlimited Jetpack Time
      - Camera Stops
      - Camera Follows


      Non-Jailbroken & No Jailbreak required hack(s): [IPA Mod Menu] Subway Surfers v3.40.0 +20 Jailed Cheats [ Currencies + More ] - ViP Non-Jailbroken Hacks & Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 40 replies
    • Mob Control v2.86.0 +7 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Mob Control By Voodoo
      Bundle ID: com.vincentb.MobControl
      iTunes Store Link: https://apps.apple.com/us/app/mob-control/id1562817072?uo=4


      Hack Features:
      - Unlimited Coins -> Earn or spend some.
      - Unlimited Skip'Its -> Earn or spend some.
      - Unlimited Stars -> Earn some.
      - Unlimited Bricks
      - Unlimited Earnt Bricks
      - Unlimited Cards -> Will increase instead of decrease.
      - No Card Requirement


      Jailbreak required hack(s): [Mod Menu Hack] Mob Control v2.78.0 +7 Cheats [ Unlimited Currencies ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 195 replies
    • Mob Control v2.86.0 +7 Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Mob Control By Voodoo
      Bundle ID: com.vincentb.MobControl
      iTunes Store Link: https://apps.apple.com/us/app/mob-control/id1562817072?uo=4


      Hack Features:
      - Unlimited Coins -> Earn or spend some.
      - Unlimited Skip'Its -> Earn or spend some.
      - Unlimited Stars -> Earn some.
      - Unlimited Bricks
      - Unlimited Earnt Bricks
      - Unlimited Cards -> Will increase instead of decrease.
      - No Card Requirement


      Non-Jailbroken & No Jailbreak required hack(s): [IPA Mod Menu] Mob Control v2.78.0 +7 Jailed Cheats [ Unlimited Currencies ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 100 replies
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines