Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Programming challenge

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Programming challenge

    My java programming class is asking me to create a program with these rules. I cannot even get the psuedocode down to start writing the program.

    Write a program that asks the user for the name of a file. The program should display only the first five lines of the files contents. If the file contains fewer than five lines, it should display the files entire contents.

    Any help will be appreciated


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Programming challenge

    Where are you stuck? Break the problem down into smaller pieces...do you know about java IO? Do you know how to ask the user and get user input?

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Programming challenge

    I am not confident in my abilities. I keep having to double back to earlier chapters to write the material. I am a complete novice. So currently no to all your questions.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Programming challenge

    I recommend to tackle each at once. The problem has specific criteria:
    • asks the user for the name of a file
    • read file
    • Display first five lines (or all if less than 5)


    Programming is a workflow often consisting of trial and error - so I encourage you to try something that would tackle each of the above in turn. I am sure your book has examples and descriptions on how to do each of the above. If not, concentrate on a specific problem, make an effort, and post a specific question should you have problems or questions.

  5. The Following User Says Thank You to copeg For This Useful Post:

    pierce21 (June 25th, 2012)

  6. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Programming challenge

    Recommended reading: Starting Writing a Program
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 3
    Last Post: January 13th, 2012, 02:11 PM
  2. Replies: 0
    Last Post: December 12th, 2011, 03:17 PM
  3. Please help me with my programming.
    By xXbrittaniXx in forum Object Oriented Programming
    Replies: 3
    Last Post: November 1st, 2011, 08:18 AM
  4. Challenge: I need an animation loop outside of the paint method.
    By Spidey1980 in forum Java Theory & Questions
    Replies: 28
    Last Post: August 20th, 2011, 09:20 AM
  5. CHALLENGE - find the shortest path
    By ice in forum Algorithms & Recursion
    Replies: 13
    Last Post: January 20th, 2011, 12:30 PM