Commission on Sales coderinme

Commission on Sales coderinme

A sales person is paid commission based on the sales he makes as shown by the following table:
SALES ……………… COMMISSION
Under SR500 ………….2 % of SALES
SR500 and under SR5000…5 % of SALES
SR5000 and over……….8 % of SALES
Write a class, Commission, which has: an instance variable, sales; an appropriate constructor; and a method, commission() that returns the commission. Now write a demo class to test the Commission class by reading a sale from the user, using it to create a Commission object after validating that the value is not negative. Finally, call the commission() method to get and print the commission. If the sales are negative, your demo should print the message “Invalid Input”. See figure (a) for sample run.
Program:
import java.io.*;
class Commission
{
private double sales;
public Commission(double s)
{
sales=s;
}
public double commission()
{
double com=0;
if (sales>=0) {
if(sales=500 && sales<5000)
com=sales*5/100;
else
com=sales*8/100;
}
else
System.out.println("Invalid input :");
return com;
}
}
public class Q23 {
public static void main(String[] args) throws IOException
{
System.out.println(" please enter the sales of the person\n ");
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
float sal=Float.parseFloat(in.readLine());
ASSIGNMENT ON JAVA
30 | Page
Commission c1=new Commission(sal);
System.out.println("The commission of the person is : "+c1.commission());
}
}

For more programs on Java, visit our Java Archives

Commission on Sales coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.