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

Thread: Please Help me to solve this algorithm for Java

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please Help me to solve this algorithm for Java

    Begining of the task:

    Peter went to book store wanted to buy books (he prepared book titles before on piece of paper) so he can fill up his home library.
    If he came to book store during the weekend (non working days) he has to go back home without books as the book store is closed, if he came on any working day he will complete shoping.
    Use if command. We know that on his shelf cannot fit more than 9 new books, so Peter will fill up his basket until he reaches that number.
    Use one of the loops: For, While, Do While.
    When Peter filled up his basket he realize that the third book from array needs to change with book called "Programming". Pay attention on indexes of array of books that are on his paper.

    End of Task

    Please help me to solve this algorithm...
    We should come up with book titles on our own.
    Thank you very much for your help

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Please Help me to solve this algorithm for Java

    What have you tried?
    Do you have any specific java programming questions?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please Help me to solve this algorithm for Java

    Quote Originally Posted by Norm View Post
    What have you tried?
    Do you have any specific java programming questions?
    I am starting to learn programming and so far we did not do any programs but only algorithms.
    So in my question is actualy task to make algorithm
    this is what I tried but the ansewer was, it is not good

    If(workingDay==true){
    inBookstore=“buyBooks“()
    string[]booksTobuy=newString[9];
    booksTobuy=["50 Shades","Emilly","Titanic","The Firm","The Third Twin","Baker Street","Biography of Mozzart",
    "Golden Hair","Zoo"];
    }
    If(nonWorkingday()){PeterStayHome();
    else"buyBooks"()
    for(i=0,˂=9,i++);
    while(atCashier)()
    string basket[i]= booksTobuy[i]
    nasket[3]="programiranje";
    kosara=[3] // goes for The Firm
    peterPay()
    }

    --- Update ---

    As far as I can see his questions are based on Java language

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Please Help me to solve this algorithm for Java

    question is actualy task to make algorithm
    Can you list the steps in the algorithm that are needed to solved the problem. Make the list in English. Do not try writing any java code yet. What you posted looks too much like code.

    When posting code, be sure to wrap it in code tags:


    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: Please Help me to solve this algorithm for Java

    Dear Norm
    That is the problem. Because where ever I look into algorithms, they do not have any code in it. But this professor is asking me to do it this way, so it sort of looks like code.
    this is the task and I can see you are the only one willing to help.
    Peter went to book store wanted to buy books (he prepared book titles before on piece of paper) so he can fill up his home library.
    If he came to book store during the weekend (non working days) he has to go back home without books as the book store is closed, if he came on any working day he will complete shoping.
    Use if command. We know that on his shelf cannot fit more than 9 new books, so Peter will fill up his basket until he reaches that number.
    Use one of the loops: For, While, Do While.
    When Peter filled up his basket he realize that the third book from array needs to change with book called "Programming". Pay attention on indexes of array of books that are on his paper.

    How would ypu write algorithm for it, baybe you put in comment what comand would you use.

    I like programming and looking forward into it but beggining is really tough. I am searching all over the internert and cannot find proper answer

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Please Help me to solve this algorithm for Java

    the ansewer was, it is not good
    What did the professor say was wrong with it.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please Help me to solve this algorithm for Java

    he did not specify that is what makes me upset. Maybe I will request someone else for help. I am doing paid online curse in Croatia, and they did not provide me with any literature or anything he is just sending tasks.

  8. #8
    Junior Member tonya's Avatar
    Join Date
    Feb 2018
    Posts
    16
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Please Help me to solve this algorithm for Java

    I think your teacher is looking for pseudo code to describe your algorithm. You can find some examples of pseudo code here.

    Try writing down your tasks on paper in the order you would do them, then try and convert the tasks into pseudo code. Once you have it looking like a logical process post it here and we can give some feed back.

  9. #9
    Junior Member
    Join Date
    Jan 2019
    Location
    Belgium
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Please Help me to solve this algorithm for Java

    Quote Originally Posted by Milenko View Post
    I am starting to learn programming and so far we did not do any programs but only algorithms.
    So in my question is actualy task to make algorithm
    this is what I tried but the ansewer was, it is not good

    If(workingDay==true){
    inBookstore=“buyBooks“()
    string[]booksTobuy=newString[9];
    booksTobuy=["50 Shades","Emilly","Titanic","The Firm","The Third Twin","Baker Street","Biography of Mozzart",
    "Golden Hair","Zoo"];
    }
    If(nonWorkingday()){PeterStayHome();
    else"buyBooks"()
    for(i=0,˂=9,i++);
    while(atCashier)()
    string basket[i]= booksTobuy[i]
    nasket[3]="programiranje";
    kosara=[3] // goes for The Firm
    peterPay()
    }

    --- Update ---
    As far as I can see his questions are based on Java language
    If your teacher is looking for pseudocode I don't know, but I do know you can't run the code you've posted, and that's even without following your logic.
    Why do you double quote some of your method names?
    It's not “buyBooks“(), but buyBooks()
    It's not while(atCashier)(), but while(atCashier()){
    and there are many more issues

Similar Threads

  1. ctt-sp algorithm(cost transitive tournament shortest path algorithm)
    By seeniya in forum Java Theory & Questions
    Replies: 3
    Last Post: April 22nd, 2014, 05:36 AM
  2. Help please to solve the Java test
    By frictionmind in forum Java Theory & Questions
    Replies: 1
    Last Post: July 19th, 2013, 07:41 AM
  3. Replies: 3
    Last Post: June 10th, 2013, 04:42 AM
  4. how do i solve this programming problem in dr java?
    By jennavg in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 8th, 2013, 12:22 PM
  5. How to solve “NullPointerException” in my Java Program ?
    By unknowny in forum Java Theory & Questions
    Replies: 8
    Last Post: July 24th, 2012, 04:06 PM