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: Any ideas?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Any ideas?

    Yes, I am new, but am eager to learn from my mistakes. I am trying to calculate the total price with sales tax, the total amount due,, the amount paid, and print the number of dollars, quarters, etc to the screen. I am getting these 4 errors, and don't know what to do to correct them.
    Here is my code:
    import java.util.Scanner;
    public class sales
    {
    public static void main(String[] args)
    {
    //Initialized objects.
    String name;
    double unitprice,totalprice,totaldue,amountpaid,change,to talpaid,
    no_dollars,no_quarters,no_dimes,no_nickles,no_penn ies;
    int item_num;
    final double tax=(0.0925);
    //Input for calculations.]
    Scanner input=new Scanner(System.in);
    System.out.println("Enter the name of the product ");
    name=input.nextString;
    System.out.println("Enter the unit price of the product ");
    unitprice=input.nextDouble();
    System.out.println("Enter the number of items sold ");
    item_num=input.nextInt;
    System.out.println("You paid "+amountpaid);
    amountpaid=input.nextDouble;
    //Calculations.
    totalprice=(unitprice*item_num);
    totaldue=totalprice*tax;
    change=totalpaid-totaldue;
    no_dollars=(int)(change)/1.00;
    System.out.println("The number of dollars of change you receive is "+no_dollars);
    no_quaters=(change-no_dollars)%0.25;
    System.out.println("The number of quarters of change you receive is "+no_quarters);
    no_dimes=(change-(no_dollars+no_quarters))%0.10;
    System.out.println("The number of dimes of change you receive is "+no_dimes);
    no_nickles=(change-(no_dollars+no_quarters+no_dimes))%0.05;
    System.out.println("The number of nickles of change you recevie is"+no_nickles);
    no_pennies=(change-(no_dollars+no_quarters+no_dimes+no_nickles))%0.01 ;
    System.out.println("The number of pennies of change you receive is"+no_pennies);
    }}


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Any ideas?

    Did you list your actual, specific errors? I can't really tell, because I can't really read unformatted code (use the highlight tags).
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Any ideas?

    All of them are cannot find symbol errors!
    name=input.nextString; //for period
    item_num=input.nextInt; //for period
    amountpaid=input.nextDouble; //for period
    no_quaters=(change-no_dollars)%0.25; //for no_quarters

  4. #4
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: Any ideas?

    input.nextString
    input.nextInt
    input.nextDouble
    These are all methods. When you call a method, you have to follow it with (). If a method takes an argument, it will be contained within the ().

    no_quaters=(change-no_dollars)%0.25
    Have you defined the variable "no_quarters" yet?
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

Similar Threads

  1. Any Program Ideas?
    By Java Programmer in forum Java Theory & Questions
    Replies: 7
    Last Post: January 18th, 2012, 08:05 AM
  2. Running out of ideas...
    By Cat in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 12th, 2011, 11:21 AM
  3. I need ideas on how to read this
    By thursgun in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: April 21st, 2010, 09:31 PM
  4. hey guys new to recursion any ideas for me?
    By JavaNoob82 in forum Algorithms & Recursion
    Replies: 4
    Last Post: February 25th, 2010, 11:27 AM
  5. Any ideas for begginer?
    By SwEeTAcTioN in forum Java Theory & Questions
    Replies: 11
    Last Post: October 27th, 2009, 03:28 AM