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

Thread: I am completely new to java And have been given this question which I don't even know how to answer

  1. #1
    Junior Member
    Join Date
    Dec 2021
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I am completely new to java And have been given this question which I don't even know how to answer

    This is the question below-
    Create the algorithmic design in structured English that will accept a sequence of numbers,
    terminated by 0 and display the sum of the numbers, the average of the numbers, the minimum
    number and the maximum number. Then code the design.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    First work on the design/algorithm - What steps does the program need to take to solve the described problem.
    Take the first requirement:
    accept a sequence of numbers, terminated by 0
    A sequence sounds like the program needs to do a loop
    What does the program need to do to accept a number?
    How to test if 0 and exit the loop
    otherwise process the number as described here:
    sum of the numbers,
    the average of the numbers,
    the minimum number
    and the maximum number.
    What does the code need to do for each of those 4 requirements?

    Get those steps worked out before thinking about writing any code.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2021
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    I get that it would be a loop or multiple loops.
    something like this in structured English-

    while ( something in here )
    begin




    end
    I just don't know what to put in here.

    I also don't understand the meaning of " accept a sequence of numbers,
    terminated by 0"

    what is the sequence of numbers? can they be any numbers I want to put through the loop?

    Also, what does it mean by terminated by 0. I get that 0 is null however I don't really know what it means or what it does.

    I also don't even know where to start with making a code that has the logic to calculate the sum, min, max and average in these loops.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    what is the sequence of numbers?
    what does it mean by terminated by 0
    I would say this is a sequence of numbers: 3 5 7 8 3 7 9 -2 77 -5 0 terminated by 0

    start with making a code
    Do not make any code until you have the steps the program is to take.

    logic to calculate the sum
    Something like this:
    initialize sum to 0
    begin loop
    get number
    add number to sum
    end loop
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2021
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    initialize sum to 0
    begin loop
    get number
    add number to sum
    end loop

    so this is the basic loop for the sum. what would the other loops look like for min, max and average?

    I also still don't know what terminated 0 means

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    what terminated 0 means
    3 2 0
    The 0 at the end of those numbers terminates the sequence of numbers.

    what would the other loops look like
    There would only be one loop. The tests for max and min would all be made inside that one loop.

    The average would be computed after the loop was done looping and all the numbers had been processed.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2021
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    okay so min, max and sum are all calculated in one loop.

    I don't even know what that would look like then.

    how do calculate 3 things in only one loop?

    so if you have a while loop like this.

    what would go in the brackets and that would somehow let you calculate the sum, min and max between the beginning and end of the loop.

    while ( something here)
    begin





    end

    Unless it has multiple loops in one loop in which I wouldn't even know what that look like.

    also, where do you even fit the sequence of numbers into this so the loops know what it is calculating?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    what that would look like then.
    Forget about the computer for now.
    If I gave you two numbers how would you determine which number was larger or smaller? You would compare their values.
    That is what max and min involves: finding the largest number and the smallest number

    the sequence of numbers
    The description you posted does not say where the sequence of numbers should come from.
    One source would be for a user to enter them
    Another source would be for the program to have a String like this: "1 3 5 3 1 0" containing the sequence
    Can you ask your instructor where the numbers come from?
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Dec 2021
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    I can enter the numbers anyway I want whether that is through a string or simply entering the numbers in.


    I understand how to find the min, max the average and the sum I just don't know how to show it in structured english.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: I am completely new to java And have been given this question which I don't even know how to answer

    how to show it in structured english.
    You will have to consult your notes or your instructor to see what is required for that. I do not have any suggestions for what is required for that.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. please answer my question.
    By sgt98 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 16th, 2014, 06:31 AM
  2. "Help with answer to question from java 6 practice exam book!
    By StanTheMan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 15th, 2013, 12:33 PM
  3. Struggling with answer to question
    By StanTheMan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 14th, 2013, 02:36 PM
  4. [SOLVED] please answer this question,tq
    By suganti selvaraj in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 6th, 2013, 12:50 AM
  5. Making sure I answered this question completely.
    By Mellowhype in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 13th, 2011, 10:53 PM

Tags for this Thread