Code:
public class SalesApp {
private String[] storeNames;
private String[] months = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
private int[] totalSales;
private int[] monthlyTotals;
private int[][] salesData;
public void initialize(String[] stores,int[][] sales) {
storeNames = stores;
salesData = sales;
}
public void totalSales() {
totalSales = new int[salesData.length];
for(int i=0;i<salesData.length;i++) {
totalSales[i] = 0;
for(int j=0;j<salesData[i].length;j++) {
totalSales[i] = totalSales[i] + salesData[i][j];
}
}
}
public void monthlyTotals() {
int rows = salesData.length;
int cols = salesData[0].length;
monthlyTotals = new int[cols];
for(int i=0;i<cols;i++) {
monthlyTotals[i] = 0;
for(int j=0;j<rows;j++) {
monthlyTotals[i] = monthlyTotals[i] + salesData[j][i];
}
}
}
public void printData() {
System.out.println("Store Location || Monthly Sales || Total Sales ");
System.out.print(" ");
for(int i=0;i<salesData[0].length;i++) {
System.out.print(months[i]+" ");
}
System.out.println();
for(int i=0;i<salesData.length;i++) {
System.out.print(storeNames[i] + " ");
for(int j=0;j<salesData[0].length;j++) {
System.out.print(salesData[i][j] + " ");
}
System.out.println(" || "+totalSales[i]);
}
System.out.print("Month Totals || ");
for(int i=0;i<monthlyTotals.length;i++) {
System.out.print(monthlyTotals[i]+" ");
}
System.out.println();
}
public static void main(String[] args) {
String[] stores = {"Chilliwack","Kamloops","Kelowna","Nanaimo","Surrey","Vancouver","Victoria"};
int[][] sales = {
{400,500,500,600,500,600},
{600,800,800,800,900,900},
{700,700,700,900,900,1000},
{500,600,700,800,700,700},
{800,700,800,700,900,800},
{1000,1100,1200,1300,1400,1400},
{900,900,900,1000,1100,1100},
};
SalesApp app = new SalesApp();
app.initialize(stores, sales);
app.totalSales();
app.monthlyTotals();
app.printData();
}
}
Output:
Store Location || Monthly Sales || Total Sales
Jan Feb Mar Apr May Jun
Chilliwack 400 500 500 600 500 600 || 3100
Kamloops 600 800 800 800 900 900 || 4800
Kelowna 700 700 700 900 900 1000 || 4900
Nanaimo 500 600 700 800 700 700 || 4000
Surrey 800 700 800 700 900 800 || 4700
Vancouver 1000 1100 1200 1300 1400 1400 || 7400
Victoria 900 900 900 1000 1100 1100 || 5900
Month Totals || 4900 5300 5600 6100 6400 6500
Design and implement an application file that does the following: • uses a 2 dimensional array...
Csharp question. Need it in 2 hours please You will complete the C# program using Windows (Not Console). The following table contains quarterly sales figures for five (5) departments: Quarter 1 Quarter 2 Quarter 3 Quarter 4 Total Department 1 750 660 910 800 Department 2 800 700 950 900 Department 3 700 600 750 600 Department 4 850 800 1000 950 Department 5 900 800 960 980 Total Design and write a Windows program/module named SalesAnalysis that will: a....
C# Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000, or a total of $650. Write an application (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges...
Please Update my C++ code: Implement array to replace for vector: Example --> input: 100 output: A 1000Pairs.txt looks like this: {100, A } {200, A } {300, B } {400, C } {500, D } {600, E } {700, F } {800, G } {900, H } {1000, I } {1100, J } {1200, K } {1300, L } {1400, M } {1500, N } {1600, O } {1700, P } {1800, Q } {1900, R } {2000, S...
please use MATlab and answer in 15 minutes
and Data 2 and the two fitted lines over the range o 3.3 Plot on the same groph Data 3.4 Find the value of x at which the two fitted lines are equal Dr Test ".il 39%)[13:43 PM VIVA Di Answer 1 of1 %Straight line, Y-MX + C X1 -0.2:0.6.2; Y1 [60 350 700 900] P1- polyfit(X1, Y1,1); YP1 polyval(P1, X1); M1 P1 (1) C1 P1(2) plot(X1, Y1 , 'ro', X1, YPI...
Java
Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a healthy, balanced diet, a grownup needs 2,250 calories a day You will write a program to track calorie intake of a person. Assignment: Calorie intake data from a person is provided in a text file named input.txt. There are arbitrary number of double values on each line, separated by spaces. The numbers represent the number of calories consumed for meals and/or snacks on a...
2) The following table provides data for an economy in a certain year 1,000 700 600 Consumption expenditures Government purchases of goods and services Construction of new homes and apartments Sales of existing homes and apartments 500 Government payments to retirees Household purchases of durable goods Beginning-of-year inventory End-of-year inventory Business fixed investment 600 300 Given the data in the table, compute the investment component of GDP A) 900 B) 400 C) 300 D) 800 3) The following table provides...
[2] The mean heat capacity (C) between two temperatures Tre and I can be calculated from ,(T)dT T-Tref (a) Use the data for the heat capacity for propane provided in the following table to calculate mean heat capacities from 400 to 1500 K using 298.3 K as the reference temperature. Fit a polynomial of suitable degree to the heat capacity data and use the resulting polynomial to evaluate the integral. (b) Calculate the mean heat capacity of propane at 1500...
write a code on .C file
Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...
This is a C++ program Instructions Design a class named PersonData with the following member variables declared as strings: lastName firstName address city state zip phone Create 3 constructors; a default constructor, a constructor that accepts the first and last name member variables, and a constructor that accepts all member variables. Write the appropriate accessor/getter and mutator/setter functions for these member variables. Create a method within this class called getFullName() that returns the person's first and last names as a...
The following transactions occurred in June 2018 for Borderline Ltd JuneReceved a cheque for S1 200 from Roar Ltd in full settlement of its account and deposited it in the bank account Sold inventory for $905(before any discounts have been applied) to Jones Ltd on credit (the company was given a trade discount of $80, then the normal credit terms) COGS was $420 Paid rent for June S1 500, chq no. 561 (Assume the rent is GST free) Purchased inventory...