Need help writing this simple java program…?
the markup of the book just sold
the wholesale amounts(to go to the publisher of the book just sold)
the total sales price of all the books sold
the total markup amount of all the books sold
Favorite Answer
import java.io.*;
import java.util.Scanner;
public class ComputeMarkup {
/* This program reads a sequence of sales prices input
by the user, and will display the markup and wholesale
cost values for each sale. At the end, the program
displays the total sales and the total markup.
*/
public static void main(String[] args) {
double salesPrice; // The price input by the user.
double wholesalePrice;
double markupAmount;
double totalSales; // The sum of the positive integers.
Scanner in = new Scanner(System.in); // The Scanner class is new in Java 1.5
/* Initialize the sum */
totalSales = 0;
/* Read and process the user’s input. */
System.out.println(“Enter your first book sales price: “);
salesPrice = in.nextDouble();
// Do this until a 0 price is entered.
while (salesPrice != 0) {
totalSales += salesPrice; // Add salesPrice to running total.
// salesPrice = wholesalePrice * 110 percent (1.1)
wholesalePrice = Math.round(salesPrice / 1.1 * 100) / 100.0;
markupAmount = Math.round((salesPrice – wholesalePrice) * 100) / 100.0;
// Print out the data
System.out.println ( ” The markup is ” + markupAmount);
System.out.println ( ” The wholesale amount is ” + wholesalePrice);
// Get the next book sale price
System.out.println(“Enter your next book sales price ( or 0.0 to end) “);
salesPrice = in.nextDouble();
}
/* Display the summary. */
System.out.println ( ” The total of all books sold is ” + totalSales);
markupAmount = Math.round(totalSales / 11.0 * 100) / 100.0;
System.out.println ( ” The total markup amount is ” + markupAmount);
} // end main()
}
================ Output from a run ==========
run:
Enter your first book sales price:
100
The markup is 9.09
The wholesale amount is 90.91
Enter your next book sales price ( or 0.0 to end)
99
The markup is 9.0
The wholesale amount is 90.0
Enter your next book sales price ( or 0.0 to end)
0
The total of all books sold is 199.0
The total markup amount is 18.09
- Academic Writing
- Accounting
- Anthropology
- Article
- Blog
- Business
- Career
- Case Study
- Critical Thinking
- Culture
- Dissertation
- Education
- Education Questions
- Essay Tips
- Essay Writing
- Finance
- Free Essay Samples
- Free Essay Templates
- Free Essay Topics
- Health
- History
- Human Resources
- Law
- Literature
- Management
- Marketing
- Nursing
- other
- Politics
- Problem Solving
- Psychology
- Report
- Research Paper
- Review Writing
- Social Issues
- Speech Writing
- Term Paper
- Thesis Writing
- Writing Styles