Includes methods which format invoice details for printing

Assignment Help JAVA Programming
Reference no: EM13940283

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;
}
}

Reference no: EM13940283

Questions Cloud

Application of data analysis within an organisation : Compute this new variable and, for each store, please draw appropriate charts. Then determine 2-sided 95% confidence intervals for the mean of the Gather Rate for each store and compare.
Debt with a yield to maturity : ABC Company has debt with a yield to maturity of 7%, a cost of common stock of 13%, and a cost of preferred stock 9%. The market values of its debt, preferred stock, and common stock are $10 millions. $3 millions, and $15 million, respectively, and i..
Trends that are affecting human resource management : This assessment addresses these learning outcomes a) Examine trends that are affecting human resource management practice
Brazil agricultural so competitive : 1. What is Brazil's agricultural so competitive? Why do its manufacturing industries lack competitiveness?2. Why have Brazil's governments in both the 20th and 21st century been eager to develop world-class manufacturing?
Includes methods which format invoice details for printing : Constructor for the Invoice class requires subtotal and customer type only
What is your best estimate of the aftertax cost of debt : Jiminy’s Cricket Farm issued a 20-year, 6 percent semiannual bond 2 years ago. The bond currently sells for 92 percent of its face value. The company’s tax rate is 40 percent. What is the company’s total book value of debt? What is your best estimate..
Journal entries to record the sale : Prepare the journal entries to record the sale on November 17 ignore the cost of goods and collection on November 26, 2016, assuming that the gross method of accounting for cash discounts is used.
What is the expected price of the stock in a year : What is the expected price of the stock in a year? Show that the expected return, 12%, equals dividend yield plus capital appreciation.
Appropriate template of a project plan online : Find an appropriate template of a project plan online. Use the template to write a plan for your project. Prepare a 30 minute PowerPoint presentation of the plan and submit it to your lecturer

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd