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

Thread: Why wont my program calculate sales tax?

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

    Question SOLVED: Why wont my program calculate sales tax?

    import javax.swing.*;
    public class Purchase
    {
     private static double invoiceNumber;
     private static double ammountOfSale;
     private static double salesTax;
     
     public double getInvoiceNumber()
     {
      return invoiceNumber;
     }
     public void setInvoiceNumber(double invoice)
     {
      invoiceNumber = invoice;
     }
     
      public double getAmmountOfSale()
     {
      return ammountOfSale;
     }
     public void setAmmountOfSale(double sale)
     {
      ammountOfSale = sale;
     }
     
     public double setSalesTax()
     {
      salesTax = .05 * ammountOfSale;
    	return salesTax;
     }
     public static void displayInfo()
     {
      JOptionPane.showMessageDialog(null, "Invoice#: " + invoiceNumber + 
    	                              "\nSale Ammount: $" + ammountOfSale +
    																"\nSales Tax: $" + salesTax);
     }
    }
    Can anyone tell me why the program will not calculate the sales tax? Thanks in advance.
    Last edited by scholaryoshi; February 28th, 2012 at 08:32 PM. Reason: Solved


  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default Re: Why wont my program calculate sales tax?

    Shoulnd't u also write a void main? there u would call the other methods as setSalesTax, then u would call displayInfo.
    I don't know much from it, just trying to solve that

  3. The Following User Says Thank You to Nhedro For This Useful Post:

    scholaryoshi (February 28th, 2012)

  4. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why wont my program calculate sales tax?

    Quote Originally Posted by Nhedro View Post
    Shoulnd't u also write a void main? there u would call the other methods as setSalesTax, then u would call displayInfo.
    I don't know much from it, just trying to solve that
    That was exactly right thank you for that out to me!

Similar Threads

  1. Replies: 3
    Last Post: October 19th, 2011, 07:57 AM
  2. anagram program wont compile please help
    By Rusak in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 26th, 2011, 06:23 PM
  3. Anagram program wont compile
    By Rusak in forum Member Introductions
    Replies: 0
    Last Post: March 25th, 2011, 02:38 PM
  4. program wont renew total
    By that_guy in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 17th, 2011, 01:00 PM
  5. Calculate federal taxes program! Help!
    By ocmjt in forum What's Wrong With My Code?
    Replies: 13
    Last Post: March 11th, 2010, 11:25 AM