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

    Default Help 2!!!!!!!!!!!!!!!!!!!!!!!!!!!

    PHP Code:
    [HTML][CODE][/CODE][/HTML]
    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;
    }
    }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

    Default

    When you post a question please use a subject related to the problem.
    Everyone posting here is looking for help.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Posting Permissions

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