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: [Help] About seminar paper (Java)

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default [Help] About seminar paper (Java)

    Guys, i need help about something in Java. Im a newbie and i don't know nothing about it so i need u're help 'cuz i need that for a seminar paper.

    I have to change computing program to programming projects, u can see an example down there:

    1. Set the starting value of money.
    2. Subtract the maximum number of quarters from money, and print the quantity
    of quarters extracted.
    3. Subtract the maximum number of dimes from money, and print the quantity of
    dimes extracted.
    4. Subtract the maximum number of nickels from money, and print the quantity of
    nickels extracted.
    5. The remainder of money is printed as pennies.
    Here is how we might write the �rst step in Java:
    int dollars = 3;
    int cents = 46;
    int money = (dollars * 100) + cents;
    The second step of the algorithm is cleverly written as follows:
    System.out.println("quarters = " + (money / 25));
    money = money % 25;
    These statements exploit integer division, /, and integer modulo, %.
    In the �rst statement, money / 25 calculates the maximum number of quarters to
    extract from money. There are two important points:
    1. The integer division operator, /, calculates integer quotient|the number of
    times 25 can be subtracted from money without leaving a negative remainder. In
    the example, since money's cell holds 346, the quotient is 13, because a maximum
    of 13 quarters (13*25 = 325) can be wholly subtracted from 346 without leaving
    a negative remainder. Here are additional examples for intuition:
    � 14 / 3 computes to 4 (and the remainder, 2, is forgotten)
    � 6 / 3 computes to 2 (and there is no remainder)
    � 4 / 5 computes to 0, because 5 cannot be wholly subtracted from 4
    2. The calculation of the division, money / 25, does not alter the value in money's
    cell, which remains 346|only an assignment statement can change the value in
    money's cell.
    The second statement, money = money % 25, deals with the second point just men-
    tioned: Since we have calculated and printed that 13 whole quarters can be extracted
    from the amount of money, we must reset the value in money's cell to the remainder.
    This can be done either of two ways:

    1. By the statement,
    money = money - ((money / 25) * 25);
    which calculates the monetary value of the extracted quarters and subtracts
    this from money.
    2. By the more elegant statement,
    money = money % 25;
    whose modulo operator, %, calculates the integer remainder of dividing money
    by 25 and assigns it to money. In this example, the remainder from performing
    346/25 is of course 21. Here are additional examples of computing remainders:
    � 14 % 3 computes to 2
    � 6 % 3 computes to 0
    � 4 % 5 computes to 4
    The combination of the integer quotient and remainder operations calculates the
    correct quantity of quarters.

    /** MakeChange calculates the change for the amounts in variables
    * dollars and cents. */
    public class MakeChange
    f public static void main(String[] args)
    f int dollars = 3;
    int cents = 46;
    int money = (dollars * 100) + cents;
    System.out.println("quarters = " + (money / 25));
    money = money % 25;
    System.out.println("dimes = " + (money / 10));
    money = money % 10;
    System.out.println("nickels = " + (money / 5));
    money = money % 5;
    System.out.println("pennies = " + money); 
         }
    }


    So, the semniar paper is this: Rebuild the change-making program, so that it uses a
    model that is this specification (watch the photo below):


    Please help, im a very amateur in this things and i don't know what to do.


  2. #2
    Administrator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,848
    Thanks
    64
    Thanked 2,645 Times in 2,615 Posts

    Default Re: [Help] About seminar paper (Java)

    Please edit your post and fix the formatting of the code. The statements should not all start in the first column. Nested statements should be indented 3-4 spaces to reflect the logic.

    Can you explain what problems you are having with the code? Describe what you want the code to do.

    Post the program's current output and add some comments to it saying what you want it to be.

  3. #3
    Elite Member curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,132
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: [Help] About seminar paper (Java)

    Cross-posted on the java-forums.org.

  4. #4
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Help] About seminar paper (Java)

    Quote Originally Posted by Norm View Post
    Please edit your post and fix the formatting of the code. The statements should not all start in the first column. Nested statements should be indented 3-4 spaces to reflect the logic.

    Can you explain what problems you are having with the code? Describe what you want the code to do.

    Post the program's current output and add some comments to it saying what you want it to be.
    It is itself uncleared like an exercise, i wrote it like it is on book :/

  5. #5
    Administrator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,848
    Thanks
    64
    Thanked 2,645 Times in 2,615 Posts

    Default Re: [Help] About seminar paper (Java)

    Can you explain why you posted the code and what you want to do with the code?

    Please edit your post and fix the formatting of the code. The statements should not all start in the first column. Nested statements should be indented 3-4 spaces to reflect the logic.

    Also posted at http://www.java-forums.org/new-java/...gram-java.html

  6. #6
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Help] About seminar paper (Java)

    Quote Originally Posted by Norm View Post
    Can you explain why you posted the code and what you want to do with the code?

    Please edit your post and fix the formatting of the code. The statements should not all start in the first column. Nested statements should be indented 3-4 spaces to reflect the logic.

    Also posted at [Help] About changing computing program (Java)
    I will post later full infos and after that u can watch it

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,431
    Thanks
    191
    Thanked 844 Times in 786 Posts
    Blog Entries
    5

    Default Re: [Help] About seminar paper (Java)

    Suggested reading: The problems with cross-posting

  8. #8
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Help] About seminar paper (Java)

    I just posted :$

  9. #9
    Administrator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,848
    Thanks
    64
    Thanked 2,645 Times in 2,615 Posts

    Default Re: [Help] About seminar paper (Java)

    Do you have any specific questions about your program?
    What have you written so far?
    What are you currently trying to write?
    Post your code and your questions.

Similar Threads

  1. Seminar
    By Finsik Gojani in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 23rd, 2012, 04:45 PM
  2. Java exam paper
    By javanoobie in forum Java Theory & Questions
    Replies: 0
    Last Post: May 3rd, 2012, 12:24 PM
  3. Help Improve My Rock,Paper,Scissors
    By Emperor_Xyn in forum Java Theory & Questions
    Replies: 3
    Last Post: December 16th, 2011, 09:34 PM
  4. rock paper si
    By robingeldolf in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 4th, 2011, 06:41 AM
  5. Paper on a Java Program
    By dude in forum Java Theory & Questions
    Replies: 1
    Last Post: December 4th, 2009, 04:40 PM