Results 1 to 2 of 2
  1. #1
    rjthomp is offline Member
    Join Date
    Jul 2015
    Posts
    2
    Rep Power
    0

    Question Error with my code

    I keep getting an error with this code and I have tried many different ways to fix it. I'm at a loss. Please help me understand how to understand and fix the error, I'm not just asking for the answer.


    import java.util.Scanner;

    public class SoftwareSales
    {
    public static void main(String[] args)
    {
    Scanner input = new Scanner(System.in);
    double Package = 99;
    double discount;
    double priceBfDiscount;
    double discountPrice;
    double totalprice;
    int quantity;

    System.out.println("This is a software sales program");

    System.out.println("Enter number of packages");
    quantity = input.nextInt();

    if (quantity >= 10 && quantity <= 19)
    discount = .20;
    if (quantity >= 20 && quantity <= 49)
    discount = .30;
    if (quantity >= 50 && quantity <= 99)
    discount = .40;
    if (quantity >= 100)
    discount = .50;

    priceBfDiscount = Package * quantity;
    discountPrice = priceBfDiscount * discount;
    totalprice = priceBfDiscount - discountPrice;

    System.out.println("The price before discount is $ " + priceBfDiscount);
    System.out.print("The discount price is $" + discountPrice);
    System.out.print("The total price is $" + totalprice);

    if (quantity >= 10 && quantity <= 19)
    {
    System.out.println("The discount is .20");
    }
    else if (quantity >=20 && quantity <=49)
    {
    System.out.println("The discount is .30");
    }
    else if (quantity >=50 && quantity <=99)
    {
    System.out.println("The discount is .40");
    }
    else if (quantity >=100)
    {
    System.out.println("The discount is .50");
    }


    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Error with my code

    1. Go through BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    Quote Originally Posted by rjthomp View Post
    I keep getting an error with this code
    2. When seeking help with an error, post the entire stack trace or in case of a compiler error, the entire error text.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. What does this error code mean?
    By Kareng in forum New To Java
    Replies: 1
    Last Post: 11-26-2012, 11:14 AM
  2. eRROR with my code not sure why
    By Exceedinglife in forum New To Java
    Replies: 1
    Last Post: 04-25-2012, 07:16 AM
  3. Error in my code
    By MikeJ39 in forum New To Java
    Replies: 2
    Last Post: 10-19-2011, 09:58 PM
  4. error in this code
    By gradiente99 in forum Eclipse
    Replies: 11
    Last Post: 07-20-2010, 05:58 PM
  5. error in code
    By dirtycash in forum New To Java
    Replies: 2
    Last Post: 12-06-2007, 11:40 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •