Program to calculate the discount amount and total

Assignment Help JAVA Programming
Reference no: EM13940405

Criterion
EnhancedInvoiceApp.java compiles
Type "R" with subtotal >= $250 and < %500 get 25% discount
Type "R" with subtotal > $500 get 30% discount
Type "C" always get 20% discount
Added new Type "T" with subtotal < $500 get 40% discount
Added new Type "T" with subtotal >= $500 get 50% discount
Types other than "C", "R" or "T" get no discount.
Introduce static method getDiscountPercentwith customer type and subtotal parameters
Move discount calculations to static method
Invoke static method to calculate discounts

Modify code
The code must be open in netbean 7.2

import java.text.NumberFormat
import java.util.Scanner;
;
public class InvoiceApp
{
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): ");
String customerType = sc.next();
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();

// get the discount percent
double discountPercent = 0;
if (customerType.equalsIgnoreCase("R"))
{
if (subtotal < 100)
discountPercent = 0;
else if (subtotal >= 100 && subtotal < 250)
discountPercent = .1;
else if (subtotal >= 250)
discountPercent = .2;
}
else if (customerType.equalsIgnoreCase("C"))
{
if (subtotal < 250)
discountPercent = .2;
else
discountPercent = .3;
}
else
discountPercent = .1;

// 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();
}
}
}

Attachment:- build.zip

Reference no: EM13940405

Questions Cloud

Development of a hospitality specific business strategy : The Marketing Campaign requires students to apply their knowledge of services marketing through the development of a hospitality specific business strategy.
What is the likely outcome if leroy agrees to review the bid : What is the likely outcome if Leroy agrees to review the bid? Is there much risk to him personally if he reviews the bid? Should the degree of risk have any bearing on his decision?
Maintaining certain amount of debt on their balance sheets : Given a 35% corporate tax rate, for every $1 in new permanent debt that the firm issues, the value of the firm increases by $0.65. The firm’s marginal tax rate may fluctuate due to changes in the tax code and changes in the firm’s income bracket. Man..
Practices by utilizing sweatshop labor : Many companies have engaged in sweatshop labor. Did the clothing company engage in unethical labor practices by utilizing sweatshop labor?
Program to calculate the discount amount and total : calculate the discount amount and total and format and display the results
What do you conclude about the relationship : What would the price and P/E ratio be if the firm paid out all earnings as dividends? What do you conclude about the relationship between growth opportunities and P/E ratios?
Firms choice of securities does not change the cash flows : As long as the firm's choice of securities does not change the cash flows generated by its assets, the capital structure decision will not change the total value of the firm or the amount of capital it can raise. If securities are fairly priced, then..
Complete a swot analysis of gambling industry : Select an industry, such as the gambling industry, to complete a SWOT analysis. Access the profile overview for the selected industry: In the University Library, click Company Directory and Financials.
What is the default risk premium on the corporate bond : If 10-year T-bonds have a yield of 6.2%, 10-year corporate bonds yield 7.4%, the maturity risk premium on all 10-year bonds is 1.3%, and corporate bonds have a 0.4% liquidity premium versus a zero liquidity premium for T-bonds, what is the default ri..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Text file containing the data

This program should begin by asking the user for the name of a text file containing the data. Then read the data which will be a line containing the dimensions of a 2 dimensional array followed by a 2 dimensional array of ints. Then perform variou..

  Explain how to declare and manipulate data in arrays

Please respond to all of the following prompts: Explain how to declare and manipulate data in arrays. Explain the meaning of "array index out of bounds".

  Write a program that takes 10 values representin

Using a loop, write a program that takes 10 values representin exam grades (between 0 and 100) from the keyboard and outputs the minimum value, maximum value, and average value of all the values entered. Your program should not accept less than 0 ..

  Rna hairpins and mirror box drawings

When the program starts up, it should draw a vertical line from the top of the screen to the bot- tom that cleanly divides the window in half. This makes it easier for the user to see the mirror effect.

  Create java servlets

Create a new JSON "view" (e.g., a JSP page that only displays the JSON representation of the data)

  Write a method to save a linked list to a text file

Write a method to save a Linked List to a text file called file.txt. It must save the Linked List to the file with each node on a different line.

  Q1write a program called linearstringsearchjava that looks

q1.write a program called linearstringsearch.java that looks for a target string value in an array of string values.

  Write a java application that calculates and displays

The application should ask the user to enter the name of the property owner and the assessed value of the property for each owner (total N owners) and calculate the property tax.

  Solve the currently very un-pc cigarette smokers problem

Write solution to solve the currently very un-PC"cigarette smokers problem" in java using Java threads, and monitors (using the "synchronized" keyword) (If it bothers your PC sensibilities, think of it at the Pot-smokers problem and then it is all pr..

  Prepare a method that takes a string as input

Prepare a method that takes a String as input and returns a String containing the middle character of the String if the length of that String is odd.

  Design a class named large integers

Design a class named largeIntegers such that an object of this class can store an integer of any number of digits.

  Java application to carry out additions and subtractions

Design a Java application to carry out additions and subtractions for numbers of any length. A number is represented as an object which includes a sign and two strings for the whole and decimal parts of the number.

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