
Concept explainers
Explanation of Solution
Modified method definition of “displayResults” in Listing 7.4:
/* Modified "displayResults" method */
public void displayResults( )
{
//Display statement for average sales per associate
System.out.print("Average sales per associate is ");
/* Display the amount of sales by calling method "writeln" in "DollarFormat" class */
DollarFormat.writeln(averageSales);
//Display statement for highest sales figure
System.out.print("The highest sales figure is ");
/* Display the highest by calling method "writeln" in "DollarFormat" class */
DollarFormat.writeln(highestSales);
//For next line
System.out.println( );
//Display statement for highest sales
System.out.println("The following had the highest sales:");
//Compute highest sales by using "for" loop
for (int i = 1; i <= numberOfAssociates; i++)
{
//Store the next sales
double nextSales = team[i].getSales( );
//Check condition
if (nextSales == highestSales)
{
/* Call "writeOutput" method to display associate name and sales amount */
team[i].writeOutput( );
/* Display above average sales by calling "write" method in "DollarFormat" class */
DollarFormat.write(nextSales - averageSales);
System.out.println(" above the average.");
System.out.println( );
}
}
//Display given statement
System.out.println("The rest performed as follows:");
/* Compute rest sales using "for" loop */
for (int i = 1; i <= numberOfAssociates; i++)
{
//Compute next sales
double nextSales = team[i].getSales( );
/* If the values in getSales is not equal to highest sales, then */
if (team[i].getSales( ) != highestSales)
{
/* Call "writeOutput" method */
team[i].writeOutput( );
/* If the value of "nextSales" is greater than or equal to "averageSales", then */
if (nextSales >= averageSales)
{
/* Display above average by calling "write" method in "DollarFormat" class */
DollarFormat.write(nextSales - averageSales);
//Display statement
System.out.println(" above the average.");
}
//Otherwise
else
{
/* Display below average by calling "write" method in "DollarFormat" class */
DollarFormat.write(averageSales - nextSales);
//Display statement
System.out.println(" below the average.");
}
//For next line
System.out.println( );
}
}
}
Explanation:
The “displayResults” method is used to display the sales reports on the screen.
- • Display statement for average sales per associate.
- • Display the amount of sales with dollar symbol by calling method “writeln()” in “DollarFormat” class.
- • Display statement for highest sales figure.
- • Display the highest sales with dollar symbol by calling method “writeln()” in “DollarFormat” class.
- • Display statement for highest sales.
- • Compute highest sales by using “for” loop.
- ○ Compute the value of “nextSales” by using method “getSales()”.
- ○ Check condition. If the value of “nextSales” is equal to “highestSales”, then call “writeOutput()” method in “salesAssociate” class to displays associate name and sales amount.
- ○ Display above average sales with dollar symbol by calling method “write()” in “DollarFormat” class.
- • Compute the rest of the sales using “for” loop.
- ○ Compute the value of “nextSales” by using method “getSales()”.
- ○ Check condition. If the values in “getSales()” is not equal to highest sales, then call “writeOutput()” method in “salesAssociate” class to prints the name and sales amount.
- ■ If the value of “nextSales” is greater than or equal to “averageSales”, then display above average value by calling “write()” method in “DollarFormat” class.
- ■ Otherwise, display below average value by calling “write()” method in “DollarFormat” class.
Completed code for method definition of “displayResults”:
The complete executable code after modifying the definition of “displayResults” method is given below:
Modified “SalesReporter.java”
//Import required package
import java.util.Scanner;
//Define "SalesReporter" class
public class SalesReporter
{
//Declare required variables
private double highestSales;
private double averageSales;
private SalesAssociate[] team;
private int numberOfAssociates;
/* Method definition for read the number of sales associates and data for each one */
public void getData( )
{
//Create object for scanner class
Scanner keyboard = new Scanner(System.in);
//Read the number of scales associates
System.out.println("Enter number of sales associates:");
numberOfAssociates = keyboard.nextInt( );
//Create object for "SalesAssociate" class
team = new SalesAssociate[numberOfAssociates + 1];
//Read data for each sales associates
for (int i = 1; i <= numberOfAssociates; i++)
{
team[i] = new SalesAssociate( );
System.out.println("Enter data for associate " + i);
team[i].readInput( );
System.out.println( );
}
}
/* Method definition for computes the average and highest sales figures */
public void computeStats( )
{
double nextSales = team[1].getSales( );
highestSales = nextSales;
double sum = nextSales;
for (int i = 2; i <= numberOfAssociates; i++)
{
nextSales = team[i].getSales( );
sum = sum + nextSales;
if (nextSales > highestSales)
highestSales = nextSales; //highest sales so far.
}
averageSales = sum / numberOfAssociates;
}
/* Modified "displayResults" method */
public void displayResults( )
{
//Display statement for average sales per associate
System...
Want to see the full answer?
Check out a sample textbook solution
Chapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Degarmo's Materials And Processes In Manufacturing
Starting Out with C++ from Control Structures to Objects (9th Edition)
Electric Circuits. (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Management Information Systems: Managing The Digital Firm (16th Edition)
- These questions are for a Computer Science course called "Theory of Computation". Provide the answers and process to the answers by using steps without little to no explanations. Provide drawings if necessary based on the questions for 1, 2a-c, and 3 based on these images provided.arrow_forwardObjective: The objective of this assignment is to gain practice with pen testing a live web application running on a remote server. The live web application is a known vulnerable web application called DVWA (Damn Vulnerable Web Application) with security settings set to low. The web app is running on an AWS EC2 (Elastic Compute Cloud) instance running Ubuntu 22. Note: The point of this assignment is to step it up a notch, we learnt about different web application vulnerabilities and applied that knowledge, now we are going to pen test and enumerable the vulnerabilities of a web app + the underlying infrastructure it is running on. Before you begin please find out what your IP address is and place it in this sheet so that I can track who is doing what: IP Addresses.docx . Tasks: 1- Start by connecting to the target, I did not install a TLS certificate on purpose that is why you are going to connect via http and not via https: http://3.99.221.134/dvwa/login.php 2- Broken Authentication:…arrow_forwardNo AI solutions pleasearrow_forward
- Create an original network topology consisting of at least seven routers and twelve links, assigning arbitrary positive weights to each link. Using this topology, apply Dijkstra's Link-State Algorithm to compute the shortest paths from a source router of your choice to all other routers in the network. Your topology must be entirely your own design and should not resemble any examples from the textbook, lecture slides, or other students' work. Al-generated topologies are not permitted. Create a PowerPoint presentation that follows the format and style of slides 11 to 23 from Lecture Slide Set 06 (LS06). You should copy those slides and make any necessary changes, additions, or deletions to reflect your own topology, shortest-path calculations, and update tables. Do not alter the original slide style, layout, or formatting.arrow_forwardCreate an original network topology consisting of at least seven routers and twelve links, assigning arbitrary positive weights to each link. Using this topology, apply Dijkstra's Link-State Algorithm to compute the shortest paths from a source router of your choice to all other routers in the network. Your topology must be entirely your own design and should not resemble any examples from the textbook, lecture slides, or other students' work. Al-generated topologies are not permitted. Createarrow_forwardx3003 x3008 1110 0000 0000 1100 1110 0010 0001 0000 0101 0100 1010 0000 x3004 0010 0100 0001 0011 x3005 0110 0110 0000 0000 X3006 0110 1000 0100 0000 x3007 0001 0110 1100 0100 0111 0110 0000 What does the following LC-3 program do? Trace Step by Step, SHOW ALL YOUR WORK. x3001 x3002 0000 x3009 0001 0000 0010 0001 X300A 0001 0010 0110 0001 x300B 0001 0100 1011 1111 x300C 0000 0011 1111 1000 X300D 1111 0000 0010 0101 x300E 0000 0000 0000 0101 x300F 0000 0000 0000 0100 x3010 0000 0000 0000 0011 x3011 0000 0000 0000 0110 x3012 0000 0000 0000 0010 x3013 x3014 0000 0000 0000 0000 0000 0100 0000 0111 x3015 0000 0000 0000 0110 x3016 0000 0000 0000 1000 x3017 0000 0000 0000 0111 x3018 0000 0000 0000 0101arrow_forward
- 2) Assume a local area network has four host computers (h1, h2, h3 & h4) and they are connected to the internet through a NAT router (s1). The host computers use private IP address space: 192.168.2/24. Each host is trying to establish 2 TCP connections to a remote webserver through the NAT router. The IP address of the webserver is: 130.12.11.9. Now do the following: 1 a. Assign IP addresses to the interfaces of the hosts and the router. For the router, assign arbitrary addresses. List these addresses. b. Now create a NAT translation table as taught in the class for all TCP connections. Assign arbitrary port numbers as required.arrow_forward1) Consider the following network. Host h6 10.3.0.6 Host h5 10.3.0.5 Host h1 10.1.0.1 OpenFlow controller m 2 3 4 Host h4 10.2.0.4 Host h2 10.1.0.2 Host h3 10.2.0.3 The desired forwarding behavior for the datagrams arriving at s2 is as follows: a) any datagrams arriving on input port 1 from hosts h5 or h6 that are destined to hosts h1 or h2 should be forwarded over output port 2; b) any datagrams arriving on input port 2 from hosts h1 or h2 that are destined to hosts h5 or h6 should be forwarded over output port 1; c) any arriving datagrams on input ports 1 or 2 and destined to hosts h3 or h4 should be delivered to the host specified; d) hosts h3 and h4 should be able to send datagrams to each other. Create a flow table for s2 that implement these forwarding behaviors. Your table should have 2 columns one for match and the other for actions, as taught in the class.arrow_forwardBased on the last digit of your Kean ID: Create an LC-3 program that compares 3 personally assigned to you numbers stored in memory and finds the maximum of them. Compile and run on https://wchargin.com/lc3web/. Screenshot and explain your result. ID 0 A 7 B с -3 12 1 0 5 -1 Expected max 12 5 2 -8 -2 6 9 My Kean ID: 1233321 3 14 3 6 14 4 -5 -6 -1 -1 сл 5 10 0 4 10 6 2 11 1 11 7 -9 7 -4 7 8 00 66 00 8 5 13 13 9 -2 3 0 3arrow_forward
Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning




