Constructor: no-argument constructor
JAVA
Suppose that one of your clients is the owner of a retail store. This retail store usually sells general merchandise every week. You are supposed to develop a simple program that will simulate the total profit of a week. The program will get the unit price of an article and calculate the actual sales price first. And then it calculates the total anticipated profit of a week. The following formula is used to calculate sales price and total profits:
- sales price = (unit price x 2) + (unit price x sales tax)
- profit of an article = (sales price - unit price) x number of the article sold
Your class should be designed as follows:
- Constructor: no-argument constructor. It initializes all variables. Sales tax is fixed to 5%.
- greeting method: It prints out greeting messages including version, date produced, and developer.
- setAll method: It asks a user to input the article name, the unit price of it, expected number of an article to be sold.
- getSalesprice method: It calculates sales price and returns it.
- getProfit method: It calculates the profit of an article and returns it.
- toString method: It prints out the result of the calculation as a table format.
Your program should be developed to test a class and get total profits of a week. And also your test program should ask a user whether or not he/she has more articles to simulate profits.
All data should be displayed as a proper format. It means unit price, sales price, profit, and total profit should be represented as a currency, and sales tax should be represented as a percentage (%).
Step by step
Solved in 6 steps with 3 images