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

Thread: Public class Sales Tax error

  1. #1
    Junior Member
    Join Date
    Jun 2021
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Public class Sales Tax error

    I am using jGrasp for Java programming. I am trying to key in public class SalesTax and it throws an error for public class.



    import java.util.Scanner; // Needed for the Scanner class /** This program calculates the total price which includes sales tax.*/ public class SalesTax { public static void main(String[] args)
    {
    // Identifier Declarations final double TAX_RATE = 0.055; double price; double tax; double total; String item; // Create a Scanner object to read from the keyboard. Scanner keyboard = new Scanner(System.in); // Display prompts and get input. System.out.print("Item description: ");
    item = keyboard.nextLine();
    System.out.print("Item price: $");
    price = keyboard.nextDouble(); // Perform the calculations. tax = price + TAX_RATE; total = price + tax; // Display the results.
    System.out.print(item + " $");
    System.out.println(price);
    System.out.print("Tax $");
    System.out.println(tax);
    System.out.print("Total $");
    System.out.println(total); } }

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,107
    Thanks
    53
    Thanked 2,618 Times in 2,568 Posts

    Default Re: Public class Sales Tax error

    it throws an error
    Please copy the full text of the error message and paste it here. It has important info about the error.

    Note: Many lines have more than one statement or } on them. Please edit the source file to change the number of statements or } on a line to one.

    Please edit your post and wrap your code with 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.

Similar Threads

  1. Java, calling another public class from within the main class giving problems.
    By RandomGaisha in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 26th, 2012, 02:30 PM
  2. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM
  3. Total Sales Error
    By KRUKUSA in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 19th, 2012, 08:20 PM
  4. What's difference between public class and abstract class?
    By Java95 in forum Java Theory & Questions
    Replies: 7
    Last Post: January 24th, 2012, 07:37 AM
  5. Public class help/error
    By Plural in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 11th, 2010, 05:22 PM