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

  Write a count occurrences() function that accepts a string

Write a CountOccurrences() function that accepts a string to be searched and a sub-string to be found. The function should return the # of times the sub-string is found. Write a tester file that declares a secret sentence as a constant.

  What is the output of the program below

What is the output when the following code fragment is executed?

  Complexity of quick sort algorithm

Write a c program to experimentally compare the O() complexities of the provided quick sort algorithm

  Monkey business, a local zoo

Monkey Business, a local zoo, wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 7 array, where each row represents a di..

  Pros and cons of choosing two servers

Classify the two alternatives in terms of what type of application architecture they use. b. Outline the pros and cons of the two alternatives and make a recommendation to Fred about which is better.

  Calculate the total as well as the average payment

Create a C++ application which will read a file of daily payments, calculate the total as well as the average payment, display the results to the screen and write the results to a file.

  Using visual c++ and your opengl configured environment

Using Visual C++ and your OpenGL configured environment, write an application that uses OpenGL Raster transformations to draw a triangle of your choice of size, location and color, and then rotate that triangle by 90 degrees and scale it by a fact..

  Reads a set of integers from file

The code in file "hw5-stree.cpp" reads a set of integers from file and inserts them into a binary search tree. You are asked to implement two functions max() and depth() that compute the maximum element and the depth of the binary search tree.

  Represents the nth fibonacci number

Prove by induction that the number of nodes in the activation tree for the Fibonacci function is 2F(n + 1) - 1.

  Longest increasing subsequence problem

Write a computer program to solve the Longest Increasing Subsequence problem.Your program should read input from a text file (one value per line

  The program should support a ''new'' feature

Write a GUI program that represents a simple Notepad clone. The program should support a 'new' feature that clears the text buffer, a save feature that writes to a file using a PrintStream

  Write c++ program to create a bar chart showing the average

Write a c++ program to create a bar chart showing the average monthly mean temperature for College Station from 2004 to 2013.

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