Displays the number invoices-average invoice amount

Assignment Help C/C++ Programming
Reference no: EM13763509

Modify the code so it displays the number of invoices, the average invoice amount, and the average discount amount when the user ends the program. Then, test this change.

import java.util.Scanner;

public class InvoiceApp

{

public static void main(String[] args)

{

// welcome the user to the program

System.out.println("Welcome to the Invoice Total Calculator");

System.out.println(); // print a blank line

// create a Scanner object named sc

Scanner sc = new Scanner(System.in);

// perform invoice calculations until choice isn't equal to "y" or "Y"

String choice = "y";

while (choice.equalsIgnoreCase("y"))

{

// get the invoice subtotal from the user

System.out.print("Enter subtotal: ");

double subtotal = sc.nextDouble();

// calculate the discount amount and total

double discountPercent= 0.0;

if (subtotal >= 200)

discountPercent = .2;

else if (subtotal >= 100)

discountPercent = .1;

else

discountPercent = 0.0;

double discountAmount = subtotal * discountPercent;

double total = subtotal - discountAmount;

// display the discount amount and total

String message = "Discount percent: " + discountPercent + "n"

+ "Discount amount: " + discountAmount + "n"

+ "Invoice total: " + total + "n";

System.out.println(message);

// see if the user wants to continue

System.out.print("Continue? (y/n): ");

choice = sc.next();

System.out.println();

}

}

}

Reference no: EM13763509

Questions Cloud

Compare and contrast japan and spain : Write the economic analysis section of a business proposal. This will include statements about the market structure and the elasticity of demand for the good or service, based on text book principles.
Discuss waterfall model technique : discuss waterfall model technique of software design
Identify an operational definition used by the researchers : Locate a recent criminal justice research article from a recognized peer-reviewed professional journal or government publication. Identify an operational definition used by the researchers
Define annual salary calculator : Create a simple ASP.NET web application using Microsoft Visual Studio 2008 that displays the text "Hello, World" on the home page. You will also add a page and build an Annual Salary Calculator on that page. This will be used as the foundation for..
Displays the number invoices-average invoice amount : Modify the code so it displays the number of invoices, the average invoice amount, and the average discount amount when the user ends the program. Then, test this change.
What rights does money matters have against hometown bank : What rights does Money Matters have against Hometown Bank, Lana's Lumberyard, and Brightday Builders
Create an asp.net web application : Create an ASP.NET web application main form containing a list of hyperlinks and images. You will also add a form with five text boxes and a Submit button.
Calculate weekly payroll : You work for a local construction firm, "DeVry Engineering Group" and your supervisor wants to test your knowledge and skills with Microsoft Excel and has instructed you to develop a spreadsheet to calculate weekly payroll for "15" employees with ..
Ethical issues or concerns about mcos providing : Discuss the ethical issues or concerns about MCOs providing a lower quality of care compared to traditional fee-for-service (FFS) organizations?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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