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

Thread: New to this..so lost trying to learn...

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default New to this..so lost trying to learn...

    I need the output to be look like this:
    Enter the amount of the purchases: (user enters 44.28)
    Enter the cash tendered: (user enters 50)

    Your change is equal to 5.71999999999 which is...
    5 dollars 72 cents
    2 quarter (s)
    2 dime(s)
    0 nickel (s)
    2 pennie (s)
    -----------------------------------------------------------
    As you can see the basic of the program is inform the user how much of each coin they get back with their change... if anyone can help me it would be a huge help!
    package lab02;
     
    /
    Purpose: Compute the amount of change a customer should
    receive (in terms of dollars, quarters, dimes, nickels, and
    pennies) given the amount of the purchase and the cash tendered.
     
    @author jdoe
     
    /
     
    import java.util.Scanner;
     
    public class Change
    {
     
    /*
    @param args
    /
    public static void main(String[] args)
    {
    double purchaseAmt;
    double cashTendered;
    double totalChange;
    int dollars, cents;
     
    // Create a Scanner object to read from standard input
    Scanner scan = new Scanner(System.in);
     
    // Prompt the user and read in amount of purchase and
    // cash tendered.
    System.out.print("Enter the amount of the purchase: ");
    purchaseAmt = scan.nextDouble();
    System.out.print("Enter the cash tendered: ");
    cashTendered = scan.nextDouble();
     
    totalChange = cashTendered - purchaseAmt;
    dollars = (int) totalChange;
     
    System.out.println();
    System.out.println ("Your change is $" totalChange
    " which is ...");
    System.out.println(dollars + " dollars");
     
    System.out.println();
     
    }
     
    }
    Last edited by copeg; September 21st, 2010 at 05:36 PM.


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

    Default Re: New to this..so lost trying to learn...

    Do you have the steps you need to take to solve your problem ie the alogrithm?
    Do you have any specific problems or questions about writing the program?

  3. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: New to this..so lost trying to learn...

    Double posted here
    http://www.javaprogrammingforums.com...ode-right.html

    ryan1234 also started three threads with the same question at the Sun/Oracle forums. The threads have been removed and the user blocked for multiposting.

    db

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: New to this..so lost trying to learn...

    I am getting blocked because i posted on two different forums is that a joke? thanks for the help.....

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: New to this..so lost trying to learn...

    It is annoying to those of us spending time answering questions to find out that the question has been answered and the time we spent working on the problem was wasted.
    A simple addition of a link to the other forums where a question is posted would be considerate to those trying to help.
    But posting three threads on one forum is a bit much.

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

    Default Re: New to this..so lost trying to learn...

    Please do not post the same question multiple times on the same forum. Your other post has been locked. Each forum has rules. Currently this forum allows posting the same question on other forums, however the reciprocal is not always the case. We do however, frown on posting the same question more than once, which is why your other post has been locked.

    Now, to the post at hand, you should first read the rules on how to place comments within code: http://java.sun.com/docs/codeconv/ht...ions.doc4.html
    Last edited by copeg; September 21st, 2010 at 05:38 PM.

Similar Threads

  1. I'm lost
    By stoptheerrors in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 31st, 2010, 08:47 AM
  2. lost
    By nyny in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 7th, 2010, 07:32 AM
  3. How long did it take you to learn?
    By JavaLearner in forum The Cafe
    Replies: 5
    Last Post: March 24th, 2010, 04:42 PM
  4. here to learn and grow
    By cejay in forum Member Introductions
    Replies: 2
    Last Post: March 1st, 2010, 03:04 AM
  5. Learn applets in java
    By mohsendeveloper in forum Java Applets
    Replies: 2
    Last Post: June 25th, 2009, 02:50 PM