Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and write a Java program that calculates and displays the results of a sales transaction. Two classes are to be defined as follows: Class

Design and write a Java program that calculates and displays the results of a sales transaction. Two classes are to be defined as follows:

Class Name: Sales

Input Variables: quantity an integer value

price a floating point value

commissionRate a double value (example: 8.5%) (to be entered as percent

discountPerCent a double value (example: 6.5%) values)

Processing: There are four input values as defined above. These variables are to be declared inside main().The main( ) method of this class should accept the quantity, price, commission rate, and discount percent from the keyboard (echo the inputs back to the screen) and call the appropriate functions described below to calculate the final sales transaction amount. main() should also display the initial sales amount.

Methods: saleAmt() The quantity and price are passed to this method. It returns the sale amount to the calling method.

netSale() The sale amount, commission amount, and discount amount are passed to this method. The commission amount should be added to the sale amount and the discount amount should be subtracted. Return the net sale back to the calling method.

finalSale() This method displays the net sale amount, tax and final sales amount. **You determine appropriate argument passing and return value.

Class Name: SalesCalcs

Methods: calcComm() The sale amount and commission rate are passed to this method. It calculates and displays the commission amount and passes this value back to the calling method.

calcDisc() The sale amount and discount percent are passed to this method. It calculates and displays the discount and passes this value back to the calling method.

tax() This method calculates the tax of the net sale amount. **You determine appropriate argument passing and return value.

roundMoney() In addition include a utility method to round all calculated values to the nearest cents amount. This method should accept a double or float as its argument and return a float value. I have included a suggested one for your convenience.

// Method to round the input value to the nearest "cents" amount

public static float roundMoney(double money)

{

int temp;

temp = (int)(money * 100.00 + .5);

return (float)temp /100;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. Place a value on the outcomes.

Answered: 1 week ago