Results 1 to 9 of 9
- 10-28-2008, 06:36 PM #1
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 @firstname.lastname@example.org the answer to the code below?
public class ValidatedCodedInvoiceApp
public static void main(String args)
Scanner sc = new Scanner(System.in);
String choice = "y";
// 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(
// 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();
"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();
private static double getDiscountPercent(String customerType,double subtotal)
double DiscountPercent = 0;
double discountPercent = 0;
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;
Last edited by wisdom4542002; 10-28-2008 at 06:51 PM. Reason: formatting
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.
- 10-28-2008, 06:50 PM #3
well i did explain that we have to validate the customer type , validate the subtotal, and discard all extra entries for the continue prompt
- 10-28-2008, 06:54 PM #4
hhhmmm ... doesn't work that way
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)
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 10-28-2008, 06:57 PM #5
well i did try and i dont know shizzit when it comes to java. i think i am gonna just try 2 make videogame.
- 10-28-2008, 07:04 PM #6supposed to validate the customer type , the subtotal,
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.
- 10-28-2008, 07:07 PM #7
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.
- 10-28-2008, 08:04 PM #8
With that image, I'd suggest you try another forum!!!
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.