Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with Java Homework!! A. Create a class named Salesperson. Data fields

ID: 643697 • Letter: N

Question

Need help with Java Homework!!

A. Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a double annual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects. Save the files as Salesperson.java and DemoSalesperson.java.

B. Modify the DemoSalesperson application so each Salesperson has a successive ID number from 111 through 120 and a sales value that ranges from $25,000 to $70,000, increasing by $5,000 for each successive Salesperson. Save the file as DemoSalesperson2.java.

Explanation / Answer

class Salesperson
{
int numberid;
double annualsale;
Salesperson(int i,double sales)
{
numberid=i;
annualsale=sales;

}

public void set(int i,double sales)
{
numberid=i;
annualsale=sales;
}

public int getnum()
{return numberid;
}
public double getsales()
{return annualsale;
}
}
class DemoSalesperson
{
public static void main(String args[])
{
Salesperson s[]= new Salesperson[9];
for(int i=0;i<9;i++)

{s[i]= new Salesperson(999,0);
System.out.println(" id number "+s[i].numberid +" annual income $"+s[i].annualsale);

}

for(int i=0;i<9;i++)
{
int n=999;
double d=25000;
s[i]= new Salesperson(n+1,d+5000);
System.out.println(" id number "+s[i].numberid +" annual income $"+s[i].annualsale);
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote