Please Write in Java
15 salesmen have performed sales in 10 different cities and the information is stored in a two-dimensional array.
For example:
City 0 |
City 1 |
City 2 |
City … |
City 9 |
|
salesman 0 |
3.4 |
4.0 |
2.6 |
…… |
3.5 |
salesman 1 |
3.7 |
4.44 |
1.90 |
…… |
5.9 |
salesman … |
1.5 |
5.9 |
7.4 |
…… |
0.0 |
salesman 14 |
44.4 |
5.6 |
7.8 |
….. |
0.9 |
Write a class called Employee that contains the following methods
Implement the main method as follows
Suppose you have already filled all the arrays.
Note: Please add question numbers as the comments.
import java.text.DecimalFormat;
public class Employee {
/**
* @param args the command line arguments
*/
private static DecimalFormat df2 = new DecimalFormat("#.##");
public static void main(String[] args)
{
//i i have just creater only array with 3 employee and you can
add
String []names={"Jay","Ajay","John"};
//ii sales 2d array data for above sales man
double [][]sales={{3.4,4.0,2.6,3.5,2.6,5.0,4.5,4.1,2.3,1.2},
{4.4,2.0,3.6,1.5,4.6,4.0,1.5,3.1,4.3,1.2},
{4.4,4.0,3.6,4.5,2.6,1.0,1.5,2.1,4.3,3.2},};
//iv
double totalSale=totalSales("John",sales,names);
System.out.println("John's total sale is : $"+
df2.format(totalSale));
sortNames(names);//iv
System.out.println("\n\n");
for(int i=0;i<names.length;i++)
{
totalSale=totalSales(names[i],sales,names);
System.out.println(names[i]+"'s total sale is : $"+
df2.format(totalSale));
}
}
//a
private static double totalSales(String name, double[][] sales,
String[] names)
{
double sum=0;
for(int i=0;i<names.length;i++)
{
if(name.equals(names[i]))
{
for(int j=0;j<sales[i].length;j++)
{
sum+=sales[i][j];
}
}
}
return sum;
}
//b
private static void sortNames(String[] names) {
for (int i = 0; i < names.length; i++)
{
for (int j = i + 1; j < names.length; j++)
{
String tmp;
if (names[i].compareTo(names[j])<0)
{
tmp = names[i];
names[i] = names[j];
names[j] = tmp;
}
}
}
}
}
output
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Please Write in Java 15 salesmen have performed sales in 10 different cities and the information...
Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer Data: Area Codes Assume you work for a company that tracks customer information, including name, gender and phone numbers Your company has a file called customers.txt which contains the following information: Jiming Wu F 4082123458 James Brown M 8315678432 Leanna Perez F 4087654433 Xing Li M 8313214555 Stacey Cahill O 8312123333 Mohammed Abbas M 4083134444 Kumari Chakrabarti F 4086667777 Shakil Smith M 4082123333 Jung...
Lab Objectives Be able to write methods Be able to call methods Be able to declare arrays Be able to fill an array using a loop Be able to access and process data in an array Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing...
********************Java Assigment******************************* 1. The following interface and classes have to do with the storage of information that may appear on a mailing label. Design and implement each of the described classes below. public interface AddrLabelInterface { String getAttnName(); String getTitle(); // Mr., Mrs., etc. String getName(); String getNameSuffix(); // e.g., Jr., III String getProfessionalSuffix(); // O.D. (doctor of optometry) String getStreet(); String getSuiteNum(); String getCity(); String getState(); String getZipCode(); } Step 1 Create an abstract AddrLabel class that implements the...
Write a Java program which will store, manipulate, and print student registration information. As part of the solution, identify the following classes: Student Admissions. The class Student must have the following fields – Name, Address, Id number, Courses, and Date, where: Name is a user defined class comprising of at minimum first name and last name. Address is a user defined class comprising of fields - street, city, state, and zip code. Date is a predefined class in the java.util...
create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the...
Java - Car Dealership Hey, so i am having a little trouble with my code, so in my dealer class each of the setName for the salesman have errors and im not sure why. Any and all help is greatly appreciated. package app5; import java.util.Scanner; class Salesman { private int ID; private String name; private double commRate; private double totalComm; private int numberOfSales; } class Car { static int count = 0; public String year; public String model; public String...
I need help with this assignment. It's due Tuesday at 8 AM. Please follow the instructions thoroughly as to not use any advanced material we may not have gone over in class. The instructions let you know what all should be used. Thanks! Use only what you have learned in Chapters 1 - 7. Use of "advanced" material, material not in the text, or project does not follow the instructions, will result in a GRADE OF 0% for the project....
Please Write the following program in c# You are to write an application which will create a company, add agents (their name, ID, and weekly sales) to that company, and printout the details of all agents in the company. The application will contain three classes: Agent.cs, Company.cs, and CompanyTest.cs (this class is already provided). Flow of the application: The CompanyTest class creates an object of the Company class and reserves space for five agents. At this point if you call...
The XYZ Company needs you to write a program that will allow them to enter the weekly sales for a salesperson and then the program will calculate things such as most sales (and what day on which they happened), least sales (and day on which they happened), total sales, and daily average. The program will need to do the following: • Validate the user input to ensure that it is not less than 0.0 (0.0 will be acceptable if there...
IN C++ Please!! Declare a global integer constant called SIZE and initialize it to 10. • Declare a global enum variable that will support 10 values – each representing an ant colony {A, B, C, D, E, F, G, H, I, J}. • In the main function, o Declare a 2-dimensional array of size the global integer constant, SIZE. The number of rows and columns should be equal to SIZE, which would make this a square matrix. This array will...