Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Question Help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    who can help me with this code? Im just beginning in java at school and I am totally lost. we are supposed to validate the customer type , the subtotal, and discard any extra entries for the continue prompt using static methods.(getValidCustomerType) static method for the cust type and (getVaildSubtota)l for the subtotal can someone email me @wisdom4542002@yahoo.com the answer to the code below?


    import java.text.NumberFormat;
    import java.util.Scanner;

    public class ValidatedCodedInvoiceApp
    {
    public static void main(String[] args)
    {
    Scanner sc = new Scanner(System.in);
    String choice = "y";

    while (!choice.equalsIgnoreCase("n"))
    {
    // get the input from the user
    System.out.print("Enter customer type (r/c/t): ");
    String customerType = sc.next();
    System.out.print("Enter subtotal: ");
    double subtotal = sc.nextDouble();



    // call the DiscountPercent method
    double discountPercent = getDiscountPercent(
    customerType,subtotal);

    // calculate the discount amount and total
    double discountAmount = subtotal * discountPercent;
    double total = subtotal - discountAmount;


    // format and display the results
    NumberFormat currency = NumberFormat.getCurrencyInstance();
    NumberFormat percent = NumberFormat.getPercentInstance();
    System.out.println(
    "Discount percent: " + percent.format(discountPercent) + "\n" +
    "Discount amount: " + currency.format(discountAmount) + "\n" +
    "Total: " + currency.format(total) + "\n");

    // see if the user wants to continue
    System.out.print("Continue? (y/n): ");
    choice = sc.next();
    System.out.println();
    }
    }
    private static double getDiscountPercent(String customerType,double subtotal)
    {
    double DiscountPercent = 0;
    double discountPercent = 0;

    if (customerType.equalsIgnoreCase("R"))
    {
    if (subtotal < 100)
    discountPercent = 0;
    else if (subtotal >= 250 && subtotal < 500)
    discountPercent = .25;
    else if (subtotal >= 500)
    discountPercent = .30;
    }
    else if (customerType.equalsIgnoreCase("C"))
    {
    discountPercent = .20;
    }
    else if (customerType.equalsIgnoreCase("T"))
    {
    if (subtotal < 500)
    discountPercent = .40;
    else if(subtotal >= 500)
    discountPercent = .50;

    }


    return discountPercent;
    }
    }
    Last edited by wisdom4542002; 10-28-2008 at 05:51 PM. Reason: formatting

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    1) email I believe goes against the spirit of this forum, that being to share problems and their solutions with everyone.
    2) why don't you go into a bit more detail on what exactly is your problem here, what is working, what isn't working, if there are any error messages, etc... A little more information on your part goes a long way.
    3) When posting code, please use code tags to help your code stay formatted and thus be readable.
    4) When posting a thread here, you'd be best served by using a subject heading that is informative, something that summarizes in a few words your problem. "help!!!!!!...." doesn't tell us much.

  3. #3
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Default

    well i did explain that we have to validate the customer type , validate the subtotal, and discard all extra entries for the continue prompt

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default hhhmmm ... doesn't work that way

    Wisdom:
    The forum deosn't work that way... the forum helps people with there code... it doesn't do homework. I would suggest that you give it a try and if you get stuck with a particular problem, when post and the forum will help.

    With that said, I would also suggest you review the following:
    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Luck...
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Default

    well i did try and i dont know shizzit when it comes to java. i think i am gonna just try 2 make videogame.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,572
    Rep Power
    25

    Default

    supposed to validate the customer type , the subtotal,
    Take the problem one step at a time.
    What does it mean to "validate" those fields? Write a small program with some variables with good and bad data and validate them.
    Post it here when you have problems.

  7. #7
    Join Date
    Oct 2008
    Posts
    7
    Rep Power
    0

    Default

    hell i'll try, i'm just lost. man the book doesn't have enough examples and when it shows 1 it has just the code its talking about. it doesn't show examples of a whole completed program.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,572
    Rep Power
    25

    Default

    With that image, I'd suggest you try another forum!!!

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Yeah, I have to second Norm's recommendation about the image. I'm somewhat surprised the the moderators haven't mentioned anything.

    Back to your problem, from my experience here and in other forums, I've found that folks who are completely lost usually can't get all that they need from within the confine's of a programmer's forum, that most of them that succeed do so through face-to-face one-on-one tutoring. Why don't you speak to your instructor to try to arrange something like this? It gives you your best chance of getting up to speed as quickly as possible.

    Best of luck.

Posting Permissions

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