Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the data file in excel called CARS. See Figure Develop a form that calcula

ID: 3736468 • Letter: U

Question

Using the data file in excel called CARS. See Figure

Develop a form that calculates and displays the results in a "List BOX" of the following questions:

1) How many cars of 8 CLY cylinders, weigh more than 3600 WGT pounds and have an MPG less than 18.

2) List of ENG model engines, which are 4 cylinders and weigh less than 2200 pounds WGT.

3) Which is the best ENG engine model that has the highest MPG, lowest CYL cylinder and least WGT Weight in this table.

(Needs the codes from that questions)

You can use "Option button" or create a button by question, it is at your discretion. There must be a button to clean the list.

2 234705205 2 33222221222 2 L G 2 2 5 0 2 2 5 G3333344443 0 441112 88888888888888466644444468888444 858675444554544 8176545610019785 2 F 12345678911234567 8901 345678901 222222233

Explanation / Answer

This is form.cs file


using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Excel = Microsoft.Interop.Excel;


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

  
private void loadExcel(object sender, EventArgs e)
{
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
Excel.Range range;

xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(@"d:csharp-Excel.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, " ", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

range = xlWorkSheet.UsedRange;
rw = range.Rows.Count;
cl = range.Columns.Count;

for (rCnt = 1; rCnt <= rw; rCnt++)
{
for (cCnt = 1; cCnt <= cl; cCnt++)
{

if (cCnt == 1)
{
int val;
val = (int)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
MPG.Add(val);

}

if (cCnt == 2)
{
int val;
val = (int)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
CYL.Add(val);

}

if (cCnt == 3)
{
int val;
val = (int)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
ENG.Add(val);

}
if (cCnt == 4)
{
int val;
val = (int)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
WGT.Add(val);

}
// str = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
//MessageBox.Show(str);
}
}
}

private void 8CLYcylindersweighmorethan3600WGpoundsandhaveanMPGlessthan18(object sender, EventArgs e)
{


for (int i = 0; i < CYL.Count; i++)
{
if (CYL[i] == 8)
{
if (WGT[i] > 3600)
{
if (MPG[i] < 18)
{
carCount++;

}
}
}
}

string count = carCount.ToString();
MessageBox.Show(count);
carCount = 0;
}
private 2ndquestion(object sender,EventArgs e)
{
for (int i = 0; i < CYL.Count; i++)
{
if (CYL[i] == 4)
{
if (WGT[i] > 2200)
{
  
  
carCount++;

  
}
}
}
string count = carCount.ToString();
MessageBox.Show(count);
carCount = 0;
}

private 3rdquestion(object sender, EventArgs e)
{
//We cannot predict the single engine model
}
}
}

Respective designer class has to be added along with this variables down:


int carCount=0;   
int rCnt;
int cCnt;
int rw = 0;
int cl = 0;
List<int> MPG = new List<int>();
List<int> CYL = new List<int>();
List<int> ENG = new List<int>();
List<int> WGT = new List<int>();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote