Purchase Solution

Enhancing the Future Value

Not what you're looking for?

Ask Custom Question

Using Netbean 7.2 create a program satisfying the following:
- Constructor for the Invoice class requires subtotal and customer type only
- Methods make discount percent, discount amount and invoice total available
- Methods include accessors and mutators for both instance variables
- Includes methods which format invoice details for printing
- Modify InvoiceApp class to create an Invoice object
- Modify InvoiceApp class to invoke a getInvoice method which displays the formatted results
- Insure that running InvoiceApp produces proper results
- Insure that all classes compile

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

public class InvoiceApp
{
public static void main(String[] args)
{
// display a welcome message
System.out.println("Welcome to the Invoice Total Calculator");
System.out.println(); // print a blank line

Scanner sc = new Scanner(System.in);
String choice = "y";
while(choice.equalsIgnoreCase("y"))
{
// get user entries
String customerType = Validator.getString(sc,
"Enter customer type (r/c): ");
double subtotal = Validator.getDouble(sc,
"Enter subtotal: ", 0, 10000);

// calculate the discount amount and total
double discountPercent = getDiscountPercent(subtotal, customerType);
double discountAmount = subtotal * discountPercent;
double total = subtotal - discountAmount;

// format the values
NumberFormat currency = NumberFormat.getCurrencyInstance();
NumberFormat percent = NumberFormat.getPercentInstance();
String sSubtotal = currency.format(subtotal);
String sCustomerType = "Unknown";
if (customerType.equalsIgnoreCase("r"))
sCustomerType = "Retail";
else if (customerType.equalsIgnoreCase("c"))
sCustomerType = "College";
String sDiscountPercent = percent.format(discountPercent);
String sDiscountAmount = currency.format(discountAmount);
String sTotal = currency.format(total);

// format and display the results
String message = "Subtotal: " + sSubtotal + "n"
+ "Customer type: " + sCustomerType + "n"
+ "Discount percent: " + sDiscountPercent + "n"
+ "Discount amount: " + sDiscountAmount + "n"
+ "Total: " + sTotal + "n";
System.out.println();
System.out.println(message);

System.out.print("Continue? (y/n): ");
choice = sc.next();
System.out.println();
}
}

static double getDiscountPercent(double subtotal, String type)
{
double discountPercent = 0.0;
if (type.equalsIgnoreCase("r"))
{
if (subtotal >= 500)
discountPercent = .2;
else if (subtotal >= 250 && subtotal < 500)
discountPercent =.15;
else if (subtotal >= 100 && subtotal < 250)
discountPercent =.1;
else if (subtotal < 100)
discountPercent =.0;
}
else if (type.equalsIgnoreCase("c"))
{
discountPercent = .2;
}
else
discountPercent = .05;

return discountPercent;
}
}.

Purchase this Solution

Solution Summary

The solution discusses enhancing the future value.

Solution provided by:
Education
  • BSc (Hons), University of Colombo - Sri Lanka
  • MEngSc, University of Melbourne
  • Certificate IV in Training & Assessment , Australian Business Council
Recent Feedback
  • "Thank you!"
  • "Thank you."
  • "Thanks a lot for you help and support"
  • "Sorry about the late payment but the assignment was sufficient and appreciated. Good work"
  • "Great description! Thank you for your quick response."
Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Javscript Basics

Quiz on basics of javascript programming language.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.