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

  Define a function hypotenuse that calculates the hypotenuse

Define a function hypotenuse that calculates the hypotenuse of a right triangle when the other two sides are given. The function should take two arguments and return the hypotenuse as a double.

  Create an employee class

Create an employee class, including two data: an employee number (type int ) and the employee's compensation (in dollars; type float). The member data should comprise an int for storing the employee number and a float for storing the employee's co..

  Atm system code two classes with related attributes

Related to ATM system code two classes with realted attributes and operations!in C++

  What more efficient way to write this function for matrix

What's a more efficient way to write this function for a matrix? This one has to go through all the numbers, but that would take too long. r_num is row and c_num is column

  Write a c program that recursively determines

Write a C program that recursively determines if a string is a palindrome. Before your program makes the palindrome determination, you must remove all punctuation characters from the string.

  Program to compute the total volume

Write a program to compute the total volume for a number of cylinders. A cylinder may have different values for height and radius.

  What does the following display

Given the subsequent array definition: double rainfall[] = {1.4, 1.2, 3.4, 1.8, 1.6}; what does the following display?

  Write a research paper on flow of control

Write a two page research paper (excluding title and reference pages) on Flow of Control.

  Convert code c to c++

I don't know where to start and how I should go about doing this and am looking for some advice - the code just has to compile in g++, it does not need to be completely rewritten in C++.

  A program that takes into account a pre given array

Problem: A program that takes into account a pregiven array and prompts the user to enter a return per minute value.

  Ansi-c program which allows the user to play a game

Your task is to write an ANSI-C program which allows the user to play a game. This will require I/O from both the user and from ?les.

  Write function to accept character array

Write down the C++ function which will accept the character array of at most 30 cells. Your function must return true if string and its reverse are identical;

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