Question

Csharp question. Need it in 2 hours please You will complete the C# program using Windows...

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. Declare a two-dimensional integer array named sales – (Note: you have 6 rows and 5 columns) - that will hold the 4 quarterly sales for 5 departments

b. Populate the first four columns for the 5 departments using the data in the preceding table.

c. Contain a loop to compute and populate the total column. Store each department’s total in the array as it is being computed.

d. Contain a loop to compute and populate the total row. Store each quarter’s total in the array as it is being computed.

e. Using a Procedure (sub program – Private or Public) format and display the table with both the row and column totals. Pass the array as an argument – ByVal.

Make sure to document and/or provide comments as much as you can. You will lose points if you have insufficient comments in the source code. Post any questions you may have on the discussion board.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Create windows form project in visual studio

//to generate form_load method double click on Form

//Now Add data grid view component to your form

//Form design

//Edit DataGridView Columns using property

//This is C# code

using System;
using System.Collections.Generic;

using System.Windows.Forms;

namespace Sales_Analysis
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
/*a two-dimensional integer array
* named sales – (Note: you have 6 rows and 5 columns) - that will hold the 4
* quarterly sales for 5 departments*/
int[,] sales = new int[6,5];//six rows and 5 columns
//populate array with values given
//First Row
sales[0, 0] = 750;
sales[0, 1] = 660;
sales[0, 2] = 910;
sales[0, 3] = 800;
//second row
sales[1, 0] = 800;
sales[1, 1] = 700;
sales[1, 2] = 950;
sales[1, 3] = 900;
//Third row
sales[2, 0] = 700;
sales[2, 1] = 600;
sales[2, 2] = 750;
sales[2, 3] = 600;
//Forth row
sales[3, 0] = 850;
sales[3, 1] = 800;
sales[3, 2] = 1000;
sales[3, 3] = 950;
//fifth row
sales[4, 0] = 900;
sales[4, 1] = 800;
sales[4, 2] = 960;
sales[4, 3] = 980;

//loops to calculate total column wise
int i, j;
//loop for rows
for(i=0;i<sales.GetLength(0)-1;i++)
{
int colTotal = 0;//to hold col total
//loop for cols
for(j=0;j<sales.GetLength(1)-1;j++)
{
//add total
colTotal = colTotal + sales[i, j];

}
//seeds total to sales array of total cols
sales[i, 4] = colTotal;
}

//loop to calculate total row wise
//loop for cols
for (i = 0; i < sales.GetLength(1) ; i++)
{
int rowTotal = 0;//to hold the total row wise
//loop for rows
for (j = 0; j < sales.GetLength(0)-1 ; j++)
{
//add total
rowTotal = rowTotal + sales[j, i];

}
//seeds total to sales array of total rows
sales[5, i] = rowTotal;
}

//call display function
display(sales);
  

}
//Parameters in C# are, by default passed by value
public void display( int[,] sales )
{
//populate data gridview with values
for (int i = 0; i < sales.GetLength(0); i++)
{
//To hold the Rows
string[] row = new string[sales.GetLength(1)];
for (int j = 0; j < sales.GetLength(1) ; j++)
{
//add the Values to rows after casting it to String
row[j] = sales[i, j].ToString();

}
//add row to DataGridView Rows
dataGridView1.Rows.Add(row);
}

}
}
}

//output

//if you need any help regarding this solution ............ please leave a comment ............ thanks

Add a comment
Know the answer?
Add Answer to:
Csharp question. Need it in 2 hours please You will complete the C# program using Windows...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • what is the equilibrium unemployment rate abd the cyclical unemployment in the case if tbis question...

    what is the equilibrium unemployment rate abd the cyclical unemployment in the case if tbis question and hkw di you find it? thanks! Consider the following table in which columns (1) and (2) give information about the initial short-run aggregate supply curve for the fictional country of Zerovia. Column (3) shows total employment at different output levels. There are eight million workers in the total labour force. Usually, 500 000 workers are structurally or frictionally unemployed. TABLE ONE (6) (1)...

  • Consider the following table in which columns (1) and (2) give information about the initial short-run...

    Consider the following table in which columns (1) and (2) give information about the initial short-run aggregate supply curve for the fictional country of Zerovia. Column (3) shows total employment at different output levels. There are eight million workers in the total labour force. Usually, 500 000 workers are structurally or frictionally unemployed. TABLE ONE show (1) Price Level (Index) 115 110 105 100 95 750 (2) (3) (5) Aggregate Total Output Output tout Output OutputEmployment Demanded Demanded Demanded billion...

  • You will complete this program using Windows (the one that uses #include ). For this project,...

    You will complete this program using Windows (the one that uses #include ). For this project, we will see what it's like to write a simple windows application program that we can perform easily in our heads. You'll find that writing programs is similar to explaining things to a 5-year-old. You are to make this program "user friendly". In other words, make sure valid data has been entered. You are to create a simple change program. The user enters the...

  • Please solve only if you know how to do it. Write the code using C++ (not...

    Please solve only if you know how to do it. Write the code using C++ (not Python or Java). Show and explain everything neatly. COMMENTS (7.5% of programming assignment grade): Your program should have at least ten (10) different detailed comments explaining the different parts of your program. Each individual comment should be, at a minimum, a sentence explaining a particular part of your code. You should make each comment as detailed as necessary to fully explain your code. You...

  • 29. (20 points) Write the complete C++ program that implements the following program, as if you...

    29. (20 points) Write the complete C++ program that implements the following program, as if you were turning this in for homework. Your program should have a commented header (your name, etc), comments within the program and a well-built display for the output. Don't forget the pre-processor commands Define an array called nums with a maximum of 20 integers, and fill the array with numbers, recei the keyboard (prompt for the numbers.) In this program, exactly 20 integers will be...

  • For this program you create a program with multiple functions using C++ 1) You will need...

    For this program you create a program with multiple functions using C++ 1) You will need a function that creates an array of 100 random numbers that are generated between and including 20 and including 40. This must be a two dimensional array of 10 numbers in a row with a total of 10 rows. 2) A function that will store the array of random numbers in a data file called "rannum". 3) A function must then read the data...

  • C# WINDOWS FORMS APPLICATION (not CONSOLE APPLICATION ) (Please screenshot window form of this program and...

    C# WINDOWS FORMS APPLICATION (not CONSOLE APPLICATION ) (Please screenshot window form of this program and write code on computer. Thank you very much !) For this week's assignment , create and complete a Windows application for the following question. Airline Reservation System: An airline has just bought a computer for its new reservation system. Develop a new system to assign seats on the new airplane( capacity: 10 seats) Display the following alternatives: "Please type 1 for first class, and...

  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • I am using C++ Write a program to determine if a gird follows the rules to...

    I am using C++ Write a program to determine if a gird follows the rules to be classified as a Lo Shu Magic Square. The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in figure below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 through 9 exactly. The sum of each row, each column, and each diagonal all add up to the same number. This is shown...

  • Please include function in this program Write a C program that will calculate the gross pay...

    Please include function in this program Write a C program that will calculate the gross pay of a set of employees utilizing pointers instead of array references. You program should continue to use all the features from past homeworks (functions, structures, constants, strings). The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. The program determines the overtime hours (anything over 40 hours), the gross pay and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT