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

  Public float usefulload()

public float usefulLoad() // this is the grossWeight - emptyWeight public float usefulLoadWithFuel( in gallons ) // this is the useful load - gallons x 6. The programmer user will pass in the number of gallons on board.

  Create blackjack program in java

Create Blackjack program in Java following the instructions below must be in NetBEans

  Mvc pattern and servlet

When you use the MVC pattern, the controller directs the flow of control to

  Convert string values from keyboard to numeric values

How do we convert string values from the keyboard to numeric values? How do we create output strings containing the values from our variables and how to answer the problem? Any help would be appreciated.

  Create wheel 360 degree

You have to create wheel, 360 degree. That is numbered 0-36. it is supposed to be spun, and randomly lands on one of the numbers.

  Values that occur just once

This list has some values that occur just once (1, 3, 4, 11, 13, 18), some values that occur twice (9, 16), some values that occur three times (14, 19) and a single value that occurs four times (7). Therefore, the call of list.maxCount() should re..

  You have in your program an arraylist which contains

you have in your program an arraylist that contains employee salaries double type in arbitrary order. you need to

  Create a folder with yourlastnamefirstinitialle73

Create a folder with YourLastNameFirstInitialLE73. Inside of that folder create 3 more folders:  In DrJava create a project folder (Creating Projects in DrJava.pdf )  asYourLastNameFirstInitialLE73.

  Write a program in which a ball is released

Write a program in which a ball is released from a user-defined height and free-falls to the ground. The ball is pulled by earth's gravity of 9.8 m/sec 2 . Assume that each pixel represents 1 cm. Once the ball hits the ground

  Implement an iterative method with a for loop

Different scientists have developed Predator-Prey models to try to understand the interactions and foresee the evolution of the populations.

  Consider an array of integers

Consider an array of integers as below: int[] a = {5, 2, -4, 3, 0, -5, 7, 11, 6, 13} Complete the method named count(int[] a) in the class Count. The method should return the number of positive numbers in the array

  Write a server for multiple clients

Write a server for multiple clients. The client sends loan information (annual interest rate, number of years, and loan amount) to the server. The server computes monthly payment and total payment and sends them back to the client.

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