1. Design an algorithm that will input sales volume records (until -1) from the
ID: 3940065 • Letter: 1
Question
1. Design an algorithm that will input sales volume records (until -1) from the user and print the sales commission owing to each salesperson. Input includes salesperson number, name and that person's volume of sales for the month. The commission rate varies according to the sales volume:
On sales volume of : Commission rate (%):
$0.00-$200.00 %5
$200.01-$1000.00 %8
$1000.01-$2000.00 %10
$2000.01 and above %12
Commission = commission rate * volume Your program is to print the salesperson's number, name, volume of sales and calculated commission.
please use a function!!!! (Method)
Explanation / Answer
import java.util.Scanner;
public class Test
{
public static void main(String args[])
{
int n;
Scanner s=new Scanner(System.in);
System.out.println("enter how many persons :");
n=s.nextInt();
for(int i=0;i<n;i++)
{
System.out.println("Person "+i+1);
System.out.println(" enter name :");
String name=s.nextLine();
System.out.println("enter id : ");
int id=s.nextInt();
System.out.println("enter sales volume for month : ");
double sales=s.nextDouble();
salesCommission(id,name,sales);
}
}
public static void salesCommission(int salesPersonNo,String name,double salesVol)
{
double commission;
double commissionRate;
if(salesVol>=0.0&&salesVol<=200.0)
commissionRate=0.05;
else if(salesVol>=200.01&&salesVol<=1000.0)
commissionRate=0.08;
else if(salesVol>=1000.01&&salesVol<=2000.0)
commissionRate=0.1;
else if(salesVol>=2000.01)
commissionRate=0.12;
commission=commissionRate*salesVol;
System.out.println("ID : "+salesPersonNo+" Name : "+name+" sales : "+salesVol+" commission : "+commission);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.