Question: PROGRAM LANGUAGE: C# Here are the instructions, Array of a structure. Create a project to analyze an income survey. The statistics for each home include

PROGRAM LANGUAGE: C#

Here are the instructions,

"Array of a structure. Create a project to analyze an income survey. The statistics for each home include an identification code, the number of members in the household, and the yearly income.

The Menus will include File, Reports, and Help. The File menu will contain Enter Data and Exit. As The data are entered, they should be assigned from the text boxes to the elements of a structure.

The reports for the project will be sent to the Print Preview Dialog. Each report should include a title, the programmer name, and the labels identifying the data.

Report 1: A report that displays the input data.

Report 2: A two-Coloumn report listing of the identification number, income for each household that exceeds the average income. The calculated average income should display at the top of the report.

Report 3: The percentage of households that have incomes below the poverty level.

Poverty Guidelines for 2008

Family Size Income
1 10210
2 13690
3 17170
4 20650
5 24130
6 27610
7 31090
8 34570
For each additional person add

3480

Here is the Code that I am having trouble with: "

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace chapter8 { public partial class Form1 : Form { struct Income { public int IdNumber; public int Nop; public double AnnualIncome; }

int cnt; Income[,] Inc; double total; double Avg;

public Form1() { InitializeComponent(); }

private void enterDataToolStripMenuItem_Click(object sender, EventArgs e) { txtIdentificationCode.Enabled = true; txtNum.Enabled = true; txtYearlyIncome.Enabled = true; txtIdentificationCode.Focus(); enterDataToolStripMenuItem.Enabled = true; btnClear.Enabled = true;

}

private void exitToolStripMenuItem_Click(object sender, EventArgs e) { this.Close(); }

private void Form1_Load(object sender, EventArgs e) { cnt = 1; total = 0;

}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { frmAbout FrmAbout = new frmAbout();

FrmAbout.ShowDialog();

}

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Font PrintFont = new Font("Arial", 30); Font MyFont = new Font("Arial", 34); float LineHeightSingle = (PrintFont.GetHeight() + 2); float HorizontalPrintLocationSingle = e.MarginBounds.Left; float VerticalPrintLocationSingle = (e.MarginBounds.Top + 150);

e.Graphics.DrawString("Input Data Report", MyFont, Brushes.Black, 100, 100); e.Graphics.DrawString("ID", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle); e.Graphics.DrawString("Persons", PrintFont, Brushes.Black, (HorizontalPrintLocationSingle + 200), VerticalPrintLocationSingle); e.Graphics.DrawString("Income", PrintFont, Brushes.Black, (HorizontalPrintLocationSingle + 400), VerticalPrintLocationSingle);

VerticalPrintLocationSingle += LineHeightSingle;

string s1; string s2; string s3;

for (int i = 1; i <= cnt - 1; i++) {

s1 = Inc[i, 0].IdNumber.ToString(); s2 = Inc[i, 1].Nop.ToString(); s3 = Inc[i, 2].AnnualIncome.ToString();

e.Graphics.DrawString(s1, PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle); e.Graphics.DrawString(s2, PrintFont, Brushes.Black, HorizontalPrintLocationSingle + 200, VerticalPrintLocationSingle); e.Graphics.DrawString(s3, PrintFont, Brushes.Black, HorizontalPrintLocationSingle + 400, VerticalPrintLocationSingle);

VerticalPrintLocationSingle += LineHeightSingle;

} }

private void inputDataReportToolStripMenuItem_Click(object sender, EventArgs e) { printPreviewDialog1 = new PrintPreviewDialog(); printPreviewDialog1.Document = printDocument1; printPreviewDialog1.ShowDialog(); }

private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) {

Font PrintFont = new Font("Arial", 30); Font Myfont = new Font("Arial", 32); float LineHeightSingle = (PrintFont.GetHeight() + 2); float HorizontalPrintLocationSingle = e.MarginBounds.Left; float VerticalPrintLocationSingle = (e.MarginBounds.Top + 150);

int n; n = cnt - 1;

if (n > 1) { Avg = (total / n); }

e.Graphics.DrawString("Average income Exceeded Report", Myfont, Brushes.Black, 100, 100); e.Graphics.DrawString("ID", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle); e.Graphics.DrawString("Persons", PrintFont, Brushes.Black, HorizontalPrintLocationSingle + 200, VerticalPrintLocationSingle); e.Graphics.DrawString("Income", PrintFont, Brushes.Black, HorizontalPrintLocationSingle + 400, VerticalPrintLocationSingle);

VerticalPrintLocationSingle += LineHeightSingle;

string s1; string s2; string s3;

for (int j = 1; j <= cnt - 1; j++) {

if (Inc[j, 2].AnnualIncome > Avg) { s1 = Inc[j, 0].IdNumber.ToString(); s2 = Inc[j, 1].Nop.ToString(); s3 = Inc[j, 2].AnnualIncome.ToString();

e.Graphics.DrawString(s1, PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle); e.Graphics.DrawString(s2, PrintFont, Brushes.Black, HorizontalPrintLocationSingle + 200, VerticalPrintLocationSingle); e.Graphics.DrawString(s3, PrintFont, Brushes.Black, HorizontalPrintLocationSingle + 400, VerticalPrintLocationSingle);

VerticalPrintLocationSingle += LineHeightSingle; } } }

private void averageIncomeExceededReportToolStripMenuItem_Click(object sender, EventArgs e) { if (printPreviewDialog1 == null) {

printPreviewDialog1 = new PrintPreviewDialog(); } printPreviewDialog1.Document = printDocument2; printPreviewDialog1.ShowDialog(); }

private void incomeBelowPovertyReportToolStripMenuItem_Click(object sender, EventArgs e) { printPreviewDialog1.Document = printDocument3; printPreviewDialog1.ShowDialog();

}

private void printDocument3_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Font PrintFont = new Font("Arial", 30); Font Myfont = new Font("Arial", 32); float LineHeightSingle = (PrintFont.GetHeight() + 2); float HorizontalPrintLocationSingle = e.MarginBounds.Left; float VerticalPrintLocationSingle = (e.MarginBounds.Top + 150);

int temp = 0; double percent; int pl = 0;

for (int j = 1; j <= cnt - 1; j++) { switch (Inc[j, 1].Nop) { case 1: if (Inc[j, 2].AnnualIncome < 10210) { pl++; }

break; case 2: if (Inc[j, 2].AnnualIncome < 13690) { pl++; } break; case 3: if (Inc[j, 2].AnnualIncome < 17170) { pl++; } break; case 4: if (Inc[j, 2].AnnualIncome < 20650) { pl++; } break; case 5: if (Inc[j, 2].AnnualIncome < 24130) { pl++; } break; case 6: if (Inc[j, 2].AnnualIncome < 27610) { pl++; } break; case 7: if (Inc[j, 2].AnnualIncome < 31090) { pl++; } break; case 8: if (Inc[j, 2].AnnualIncome < 34570) { pl++; } break;

} if (Inc[j, 1].Nop > 8) { temp = (Inc[j, 1].Nop - 8) * 3480 + 34570; if (Inc[j, 2].AnnualIncome < temp) { pl += 1; } } } percent = (pl / (cnt - 1)) * 100; percent.ToString("##");

e.Graphics.DrawString(percent + "%", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle);

}

private void btnSubmit_Click(object sender, EventArgs e) { string idNumber = txtIdentificationCode.Text.ToString(); string nop = txtNum.Text.ToString(); string annualIncome = txtYearlyIncome.Text.ToString();

Inc[cnt, 0].IdNumber = int.Parse(idNumber); Inc[cnt, 1].Nop = int.Parse(nop); Inc[cnt, 2].AnnualIncome = double.Parse(annualIncome);

MessageBox.Show("Data has been Entered");

total += Inc[cnt, 2].AnnualIncome;

txtIdentificationCode.Clear(); txtNum.Clear(); txtYearlyIncome.Clear();

cnt += 1;

}

private void btnClear_Click(object sender, EventArgs e) { txtIdentificationCode.Clear(); txtNum.Clear(); txtYearlyIncome.Clear();

txtIdentificationCode.Focus();

} } }"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!