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 4 of 4

Thread: 1d Arrays and inFile. HELP!

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 1d Arrays and inFile. HELP!

    Ok, so I'm taking my CS2401 class at my university but I took a year and a half break of no java programming whatsoever... I'm VERY rusty right now /: So I basically need some help starting the code like how to import and use the inFile scanner reader and how to create the array etc.

    So the instructions are:

    "A local fitness company has contracted you to create a simple diet tracking software that will help clients count calories.

    The client will provide data in the form of a text file. There are three numbers on each line, separated by spaces. The numbers represent the number of calories consumed for breakfast, lunch, and dinner. For part 1, assume that the file includes data for exactly one week (7 lines of text). The program should read the data from the file into three separate arrays, one each for breakfast, lunch, dinner. Then compute and print out the following in different methods each:

    -a list of total number of calories consumed each day.
    -the avg number of calories consumed each day
    -the avg number of calories consumed in each of the three meals
    -the maximum number of calories consumed in any specific day
    -the max number of calories consumed in any one meal (of any type)

    YOU SHOULD PRINT AN ERROR MESSAGE AND TERMINATE IF THERE ARE NOT EXACTLY THREE NUMBERS ON EACH LINE, AND EXACTLY 7 LINES OVERALL."

    Your help will be very appretiated


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,542
    My Mood
    Grumpy
    Thanks
    0
    Thanked 166 Times in 157 Posts

    Default Re: 1d Arrays and inFile. HELP!

    Do you need someone to write the code for you?
    Improving the world one idiot at a time!

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,354
    Thanks
    49
    Thanked 2,206 Times in 2,179 Posts

    Default Re: 1d Arrays and inFile. HELP!

    Here is a useful Tutorial. Go to this site and Find Arrays
    Trail: Learning the Java Language: Table of Contents (The Java Tutorials)
    For the Scanner class, go to this site and Find Scanner:
    Java Platform SE 6

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: 1d Arrays and inFile. HELP!

    Please make sure you post your thread in the correct forum.
    There's no point posting in "Whats wrong with my code" forum when you have written no code!!

    I have moved the thread.

    http://www.javaprogrammingforums.com...ner-class.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. Need Help with Arrays
    By zennbang in forum Object Oriented Programming
    Replies: 3
    Last Post: July 31st, 2011, 06:41 AM
  2. Arrays
    By av8 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 25th, 2011, 01:21 PM
  3. 3 Arrays
    By D3158 in forum Collections and Generics
    Replies: 27
    Last Post: June 16th, 2011, 11:10 AM
  4. Arrays
    By mlan in forum Java Theory & Questions
    Replies: 2
    Last Post: February 26th, 2010, 09:23 AM
  5. 2d Arrays
    By mgutierrez19 in forum Collections and Generics
    Replies: 5
    Last Post: October 27th, 2009, 04:08 PM

Tags for this Thread