Create a class Java that contains sales person information. Part 1 Write a progr
ID: 3665287 • Letter: C
Question
Create a class Java that contains sales person information.
Part 1
Write a program that contains a SalesPerson class. The SalesPerson class should store a salesperson’s name and sales total.
You should write get/set methods for the name and sales total class variables.
Write a method called StatusMessage() that will print “Performing well” if the sales total is >= 100 otherwise print “Not meeting expectations”.
Inside of main() create an instance of the SalesPerson class. Use the set methods to put data into the instance. You should also call the StatusMessage() method from main().
Explanation / Answer
import java.util.*;
/*declaring a class Sales Person with variables name salestotal */
class SalesPerson{
String name;
int salestotal;
/*set and get metod for sales person name*/
public void setName(String s) {
name = s;
}
public String getName() {
return name;
}
/*set and get metod for sales person total*/
public void setsalestotal (int t) {
salestotal = t;
}
public int getsalestotal () {
return salestotal ;
}
/* declaring StatusMessage() that will print “Performing well” if the sales total is >= 100 otherwise print “Not meeting expectations”*/
public void statusMessage()
{
if(salestotal >= 100)
System.out.println("Performing well");
else
System.out.println("Not meeting expectations");
}
{
SalesPerson sp= new SalesPerson ();
System.out.println("Enter Sales person Name: ");
InputStreamReader r=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(r);
System.out.println("Enter Sales person Name: ");
String name=br.readLine();
sp.getsalestotal(total);
sp. statusMessage();}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.