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.

Answers

Answer 1

Answer:

Here is the modified DemoSalesperson2

public class DemoSalesperson2{ // class DemoSalesperson2

public static void main(String[] args) { //start of main() function body

SalesPerson[] sp = new SalesPerson[10]; // creates an array of SalesPerson object named sp

int start_id =111; // assign 111 to starting id number

double start_sal=25000; //assign 25000 to starting salary means salary will start from amount 25000

 for (int i =0; i<sp.length; i++) { //loop iterates until the value of loop variable i remains less then length of the array object sp

  sp[i] =new SalesPerson(start_id+i,start_sal+5000*(i)); /*at each iteration  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 is displayed using object array sp[] which calls the SalesPerson constructor to access id and sales */

 System.out.println(sp[i].getId()+"   "+sp[i].getAnnualSales() );  } } } /*uses object sp of class SalesPerson to access the methods getId which returns the id and getAnnualSales method which returns the annual sales, to display id and annual sales */

Explanation:

The question first requires a SalesPerson class with these requisites:

Class name: Salesperson.

Data fields for Salesperson: int ID number , double annual sales amount.

Methods: constructor SalesPerson() that requires values for both data fields, as well as get and set methods for each of the data fields.

So according to the complete question's requirement, I have implemented SalesPerson class:

public class SalesPerson {   // class name

//data members: integer type id variable and double type sales variable

   private int id;  

   private double sales;  

   public SalesPerson(int id_no, double annual_sales) {   //constructor that requires values for id and sales

       id = id_no;  

       sales = annual_sales;     }  

   public int getId() {   //accessor getId() method to get or access the value of id data field

       return id;     }  

   public void setId(int id_no) {   //mutator setId to set the value of id data field

       id = id_no;     }  

   public double getAnnualSales() {   //accessor getAnnualSales() method to get or access the value of sales data field

       return sales;     }  

   public void setAnnualSales(double annual_sales) { //mutator setAnnualSales to set the value of sales data field

       sales = annual_sales;     }  }

However you can use my DemoSalesperson2 application for your own SalesPerson class.

Now I will explain the working of for loop used in DemoSalesperson2

Iteration 1:

i=0

i<sp.length is true because length of sp[] is 10 so i<10

This means the body of for loop will execute.

The statement inside the body of for loop is :

 sp[i] =new SalesPerson(start_id+i,start_sal+5000*(i));

class SalesPerson constructor is used to access the data members of SalesPerson class

start_id = 111

start_sal=25000

start_id+i = 111 + 0 = 111

start_sal+5000*(i) = 25000 + 5000 (0) = 25000

The values 111 and 25000 are stored to sp[0] means at the first index of the sp array.

System.out.println(sp[i].getId()+"   "+sp[i].getAnnualSales() );  

This statement uses sp object to get access to the getId and getAnnualSales methods to print the id number and sales amount.

So the output at 1st iteration is:

111   25000.0

Iteration 1:

The value of i is incremented to 1 so now i = 1

i<sp.length is true because length of sp[] is 10 so i<10

This means the body of for loop will execute.

The statement inside the body of for loop is :

 sp[i] =new SalesPerson(start_id+i,start_sal+5000*(i));

class SalesPerson constructor is used to access the data members of SalesPerson class

start_id = 111

start_sal=25000

start_id+i = 111 + 1 = 112

start_sal+5000*(i) = 25000 + 5000 (1) = 25000 + 5000 = 30000

The values 111 and 25000 are stored to sp[1] means at the first index of the sp array.

System.out.println(sp[i].getId()+"   "+sp[i].getAnnualSales() );  

This statement uses sp object to get access to the getId and getAnnualSales methods to print the id number and sales amount.

So the output at 1st iteration is:

112   30000.0

The loop keeps iterating and the value of id is incremented by 1 and value of sales is increased by 5000 at every iteration.

This loop continues to execute until the value of i exceeds the length of sp array i.e. 10.

The values from iteration 1 to 8 following the above explanation are:

Iteration 1:

111    25000.0

Iteration 2:

112    30000.0

Iteration 3:

113    35000.0

Iteration 4:

114   40000.0  

Iteration 5:

115   45000.0  

Iteration 6:

116   50000.0                                                          

Iteration 7:

117   55000.0                                                                                                      

Iteration 8:                                                                                      

118   60000.0      

Iteration 9:                                                                                    

119   65000.0

Iteration 10:                                                                                    

120   70000.0

At iteration 11 the for loop body will not execute as value of i at 11th iteration is i = 10 and i<sp.length evaluates to false as i = sp.length because length of sp array is 10 and now the value of i is also 10. So the loop ends. Screenshot of the program and its output is attached.

Modify The DemoSalesperson Application So Each Salesperson Has A Successive ID Number From 111 Through

Related Questions

What are the pros and cons of using a linked implementation of a sparse matrix, as opposed to an array-based implementation?

Answers

Answer:

Linked lists and arrays are both linear data structures but while an array is a collection of items that can be accessed randomly, a linked list can be accessed sequentially.

A sparse matrix contains very few non-zero elements. For example;

_                        _

|  0   0   3  0  6    |

|   0   5   0  0  4   |

|   2   0   0  0  0   |

|_ 0   0   0  0  0 _|

In the implementation of a sparse matrix, the following are some of the pros and cons of using a linked list over an array;

PROS

i.  Linked lists are dynamic in nature and are readily flexible - they can expand and contract without having to allocate and/or de-allocated memory compared to an array where an initial size might need to be set and controlled almost manually. This makes it easy to store and remove elements from the sparse matrix.

ii. No memory wastage. Since the size of a linked list can grow or shrink at run time, there's no memory wastage as it adjusts depending on the number of items it wants to store. This is in contrast with arrays where you might have unallocated slots. Also, because the zeros of the sparse matrix need not be stored when using linked lists, memory is greatly conserved.

CONS

i. One of the biggest cons of linked lists is the difficulty in traversing items. With arrays, this is just of an order of 0(1) since the only requirement is the index of the item. With linked lists, traversal is sequential which means slow access time.

ii. Storage is another bottle neck when using linked lists in sparse matrix implementation. Each node item in a linked list contains other information that needs to be stored alongside the value such as the pointer to the next or previous item.

How many times will the while loop that follows be executed? var months = 5; var i = 1; while (i < months) { futureValue = futureValue * (1 + monthlyInterestRate); i = i+1; }
a. 5
b. 4
c. 6
d. 0

Answers

Answer:

I believe it is A

Explanation:

Write code to create a list of numbers from 0 to 67 and assign that list to the variable nums. Do not hard code the list. Save & RunLoad HistoryShow CodeLens

Answers

Answer:

The program written in Python is as follows

nums = []

for i in range(0,68):

-->nums.append(i)

print(nums)

Explanation:

Please note that --> is used to denote indentation

The first line creates an empty list

nums = []

This line creates an iteration from 0 to 67, using iterating variable i

for i in range(0,68):

This line saves the current value of variable i into the empty list

nums.append(i)

At this point, the list has been completely filled with 0 to 67

This line prints the list

print(nums)

Write a program that create Employee class with fields id,name and sal and create Employee object and store data and display that data.

Answers

Answer:

Here is the C++ program for Employee class with fields id,name and sal.

#include <iostream>  // to use input output functions

#include <string>  //to manipulate and use strings

using namespace std;   // to access objects like cin cout

class Employee {  //class Employee

private:  

/* the following data members are declared as private which means they can only be accessed by the functions within Employee class */

  string name;  //name field

  int id; //id field

  double sal;   //salary field

public:    

  Employee();  // constructor that initializes an object when it is created

/* setName, setID and setSalary are the mutators which are the methods used to change data members. This means they set the values of a private fields i.e. name, id and sal */

  void setName(string n)  //mutator for name field

     { name = n; }        

  void setId(int i)  //mutator for id field

     { id = i; }        

  void setSalary(double d)  //mutator for sal field

     { sal = d; }  

/* getName, getID and getSalary are the accessors which are the methods used to read data members. This means they get or access the values of a private fields i.e. name, id and sal */

  string getName()  //accessor for name field

     { return name; }        

  int getId()  //accessor for id field

     { return id; }        

  double getSalary()  //accessor for sal field

     { return sal; }  };  

Employee::Employee() {  //default constructor where the fields are initialized

  name = "";  // name field initialized

  id = 0;  // id field initialized to 0

  sal = 0;   }   // sal field initialized to 0

void display(Employee);  

// prototype of the method display() to display the data of Employee

int main() {  //start of the main() function body

  Employee emp;  //creates an object emp of Employee class

/*set the name field to Abc Xyz which means set the value of Employee class name field to Abc Xyz  through setName() method and object emp */

  emp.setName("Abc Xyz");  

/*set the id field to 1234 which means set the value of Employee class id field to 1234  through setId() method and object emp */

  emp.setId(1234);

/*set the sal field to 1000 which means set the value of Employee class sal field to 1000  through setSalary() method and object emp */

  emp.setSalary(1000);    

  display(emp);  }   //calls display() method to display the Employee data

void display(Employee e) {  // this method displays the data in the Employee //class object passed as a parameter.

/*displays the name of the Employee . This name is read or accessed through accessor method getName() and object e of Employee class */

  cout << "Name: " << e.getName() << endl;  

/*displays the id of the Employee . This id is read or accessed by accessor method getId() and object e */

  cout << "ID: " << e.getId() << endl;

/*displays the salary of the Employee . This sal field is read or accessed by accessor method getSalary() and object e */

  cout << "Salary: " << e.getSalary() << endl;  }

Explanation:

The program is well explained in the comments mentioned with each statement of the program.

The program has a class Employee which has private data members id, name and sal, a simple default constructor Employee(), mutatator methods setName, setId and setSalary to set the fields, acccessor method getName, getId and getSalary to get the fields values.

A function display( ) is used to display the Employee data i.e. name id and salary of Employee.

main() has an object emp of Employee class in order to use data fields and access functions defined in Employee class.

The output of the program is:

Name: Abc Xyz                                                                                                      

ID: 1234                                                                                                                  

Salary: 1000

The program and its output are attached.

Distinguish among packet filtering firewalls, stateful inspection firewalls, and proxy firewalls. A thorough answer will require at least a paragraph for each type of firewall.
Acme Corporation wants to be sure employees surfing the web aren't victimized through drive-by downloads. Which type of firewall should Acme use? Explain why your answer is correct.

Answers

Answer:

packet filtering

Explanation:

We can use a packet filtering firewall, for something like this, reasons because when visiting a site these types of firewalls should block all incoming traffic and analyze each packet, before sending it to the user. So if the packet is coming from a malicious origin, we can then drop that packet and be on our day ;D

4. Discuss the advantages and disadvantages of using the same system call interface for both files and devices. Why do you think operating system designers would use the same interface for both

Answers

Answer:

According to the principles of design, Repetition refers to the recurrence of elements of the design

One of the advantages of this is that it affords uniformity. Another is that it keeps the user of such a system familiar or with the interface of the operating system.

One major drawback of this principle especially as used in the question is that it creates a familiar route for hackers.

Another drawback is that creates what is called "repetition blindness". This normally occurs with perceptual identification tasks.

The  phenomenon may be  due to a failure in sensory analysis to process the same shape, figures or objects.

Cheers!

ICMP
(a) is required to solve the NAT traversal problem
(b) is used in Traceroute
(c) has a new version for IPv6
(d) is used by Ping

Answers

Answer:

(b) is used in Traceroute

(d) is used by Ping

Explanation:

ICMP is the short form of Internet Control Message Protocol. It is a protocol used by networking devices such as routers to perform network diagnostics and management. Since it is a messaging protocol, it is used for sending network error messages and operations information. A typical message could be;

i. Requested service is not available

ii. Host could not be reached

ICMP does not use ports. Rather it uses types and codes. Some of the most common types are echo request and echo reply.

Traceroute - which is a diagnostic tool - uses some messages available in ICMP (such as Time Exceeded) to trace a network route.

Ping - which is an administrative tool for identifying whether a host is reachable or not - also uses ICMP. The ping sends ICMP echo request packets to the host and then waits for an ICMP echo reply from the host.

ICMP is not required to solve NAT traversal problem neither does it have a new version in IPV6.

Write a sentinel-controlled while loop that accumulates a set of integer test scores input by the user until negative 99 is entered.

Answers

Answer:

Here is the sentinel-controlled while loop:

#include <iostream> //to use input output functions

using namespace std; // to identify objects like cin cout

int main(){ // start of main() function body

int test_score; // declare an integer variable for test scores

//prompts user to enter test scores and type-99 to stop entering scores

cout << "Enter the test scores (enter -99 to stop): ";

cin >> test_score; // reads test scores from user

while (test_score != -99){ // while loop keeps executing until user enters -99

cin >> test_score; } } // keeps taking and reading test scores from user

Explanation:

while loop in the above chunk of code keeps taking input scores from user until -99 is entered. Sentinel-controlled loops keep repeating until a sentinel value is entered. This sentinel value indicates the end of the data entry such as here the sentinel value is -99 which stops the while loop from iterating and taking the test score input from user.

The complete question is that the code should then report how many scores were  entered and the average of these scores. Do not count the end sentinel -99 as a score.

So the program that takes input scores and computes the number of scores entered and average of these scores is given below.

#include <iostream>  // to use input output functions

using namespace std;  // to identify objects like cin cout

int main(){  //start of main function body

double sum = 0.0;  // declares sum variable to hold the sum of test scores

int test_score,count =0;  

/* declares test_scores variable to hold the test scores entered by user and count variable to count how many test scores input by user */

cout << "Enter the test scores (or -99 to stop: ";

//prompts user to enter test scores and type-99 to stop entering scores

cin >> test_score;  // reads test scores from user

while (test_score != -99){  // while loop keeps executing until user enters -99

count++;  /* increments count variable each time a test cores is input by user to count the number of times user entered test scores */

sum = sum + test_score;  // adds the test scores

cin >> test_score;}  // reads test scores from user

if (count == 0)  // if user enters no test score displays the following message

cout << "No score entered by the user" << endl;

else  //if user enters test scores

//displays the numbers of times test scores are entered by user

cout<<"The number of test scores entered: "<<count;

/* displays average of test scores by dividing the sum of input test scores with the total number of input test scores */

cout << "\n The average of " << count << " test scores: " <<sum / count << endl;}

The program along with its output is attached.

Other Questions
Mr. mahatma Gandhi an essay in English 200 words Write the following isotope in nuclide notation: oxygen-14 please help ASAP: Factorise the following: A t-shirt increased in price by 1/7. After the increase it was priced at 56. What was the original price of the t-shirt? Find the lateral area of a regular square pyramid if the base edges are of length 12 and the perpendicular height is 8. Determine if the coordinate (6, 8) lies on the circle x^2 + y^2 = 100. You are given a choice of taking the simple interest on $100,000 invested for 2 years at a rate of 3% or the interest on $100,000 invested for 2 years at an interest rate of 3% compounded quarterlyWhich investment as the greater amount of interest? Give the difference between the amounts of interest earned by the two investmentsthe investment with simple? or compound? interest earns $___ more in interest.(Round to the nearest cant as needed.) Unexpected visitor By t. Herlinger Which two phrases should be considered when predicting what Paul will do? It takes me 10 minutes to swim 2 laps. How long will it takeme to swim 5 laps? When looking at the chemical symbol, the charge of the ion is displayed as the-superscript-subscript-coefficient-product Question 19 (5 points)In fresco painting, what is a cartoon?sequential drawings of the steps and techniques used to complete the designUO a storyboard9a small sketch of the image in an artist's notebook12D a full-sized drawing of the image used to transfer the design to a wall15 A biologist samples and measures the length of the fish in a lake. What is the level of measurement of the data? Ray and Kelsey have summer internships at an engineering firm. As part of their internship, they get to assist in the planning of a brand new roller coaster. For this assignment, you help Ray and Kelsey as they tackle the math behind some simple curves in the coaster's track.Part AThe first part of Ray and Kelsey's roller coaster is a curved pattern that can be represented by a polynomial function.Ray and Kelsey are working to graph a third-degree polynomial function that represents the first pattern in the coaster plan. Ray says the third-degree polynomial has 4 intercepts. Kelsey argues the function can have as many as 3 zeros only. Is there a way for the both of them to be correct? Explain your answer.Kelsey has a list of possible functions. Pick one of the g(x) functions below and then describe to Kelsey the key features of g(x), including the end behavior, y-intercept, and zeros.g(x) = x3 x2 4x + 4g(x) = x3 + 2x2 9x 18g(x) = x3 3x2 4x + 12g(x) = x3 + 2x2 25x 50g(x) = 2x3 + 14x2 2x 14Create a graph of the polynomial function you selected from Question 2.Part BThe second part of the new coaster is a parabola.Ray needs help creating the second part of the coaster. Create a unique parabola in the pattern f(x) = ax2 + bx + c. Describe the direction of the parabola and determine the y-intercept and zeros.The safety inspector notes that Ray also needs to plan for a vertical ladder through the center of the coaster's parabolic shape for access to the coaster to perform safety repairs. Find the vertex and the equation for the axis of symmetry of the parabola, showing your work, so Ray can include it in his coaster plan.Create a graph of the polynomial function you created in Question 4.Part CNow that the curve pieces are determined, use those pieces as sections of a complete coaster. By hand or by using a drawing program, sketch a design of Ray and Kelsey's coaster that includes the shape of the g(x) and f(x) functions that you chose in the Parts A and B. You do not have to include the coordinate plane. You may arrange the functions in any order you choose, but label each section of the graph with the corresponding function for your instructor to view.Part DCreate an ad campaign to promote Ray and Kelsey's roller coaster. It can be a 15-second advertisement for television or radio, an interview for a magazine or news report, or a song, poem, or slideshow presentation for a company. These are just examples; you are not limited to how you prepare your advertisement, so be creative. Make sure to include a script of what each of you will say if you are preparing an interview or a report. The purpose of this ad is to get everyone excited about the roller coaster. In 2008 a newspaper sold 120 thousand papers, and had 60 thousands people reading online. Their online readership has been increasing by 8 thousand people each year, while their physical paper sales have decreased by 6 thousand papers a year. In what year does online readership exceed physical sales? An athlete has an enhanced genotype for carbohydrate utilization, however they feel sluggish after they eat carbohydrates, which of the following should the trainer consider?a. The type of carbohydrates being consumedb. Decrease the carbohydrate intakec. Add more caffeine to the daily dietd. They are likely over trained and tired Read the text and choose the option with the correct form of conocer in the preterite, imperfect, or progressive tense. Ayer, t ________ a Matilda, la cotorra de la seora Vilanova. A. conoca B. conocan C. conoc D. conociste In The Crucible, the author develops these themes:Personal conflicts lead to societal conflicts.Spreading lies is easier than disproving them.How do these themes interact in The Crucible, Act 3, Part 1?A.John Proctor convinces Mary Warren to deny the accusations, but she has difficulty speaking for herself.B.The Putnams accuse Giles Coreys wife after a land dispute, and the court does not accept Giless evidence in her defense.C.Danforth describes how he has arrested and convicted many of witchcraft, but he allows Proctor and Mary to state their opinions.D.Francis Nurse arrives to defend his wife from accusations, and Parris threatens to have him arrested for contempt. For what value of k will k + 9, 2k -1 and 2k + 7 are the consecutive terms of an A.P.? Two ships are located 200 m and 300 m respectively from a lighthouse. If the angle formed by their paths to the lighthouse is 96. What is the distance between the two ships? Find the lateral area of the cone in terms of pi.