Question

In: Computer Science

Must be in Visual C# using windows forms : Create an application that opens a specified...

Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.

Solutions

Expert Solution

code:

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;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;

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


private void button1_Click(object sender, EventArgs e)
{
string txt = File.ReadAllText("doc.txt");
string[] arr = txt.Split(' ');
string[] res = UniqueWords(arr);
listBox1.DataSource = res;
}

public static string[] UniqueWords(string[] input)
{
if (input == null)
return new string[0];
else
{
ArrayList arr = new ArrayList();
for (int i = 0; i < input.Length; i++)
if (!arr.Contains(input[i]))
arr.Add(input[i]);
return (string[])arr.ToArray("".GetType());
}
}
}
}

Design:

namespace UniqueWordsForm
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(84, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Unique words";
//
// button1
//
this.button1.Location = new System.Drawing.Point(340, 144);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(107, 53);
this.button1.TabIndex = 3;
this.button1.Text = "Process file";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(87, 144);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 173);
this.listBox1.TabIndex = 4;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(538, 375);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "te";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ListBox listBox1;
}
}


Related Solutions

***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class named PersonEntry. The PersonEntry class should have properties for a person’s name, e-mail address, and phone number. Also, create a text file that contains the names, e-mail addresses, and phone numbers for at least five people. When the application starts, it should read the data from the file and create a PersonEntry object for each person’s data. The PersonEntry objects should be added to...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might use to represent a character within the game. A character should include six stats as instance variables – strength, dexterity, constitution, intelligence, wisdom and charisma (all types are int). Your class should have a constructor that initializes these six instance variables. Provide Properties with an appropriate set and get block for each instance variable. In addition, provide a method named getStatsTotal that calculates the...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
Using Visual Studio in C#; create a grading application for a class of ten students. The...
Using Visual Studio in C#; create a grading application for a class of ten students. The application should request the names of the students in the class. Students take three exams worth 100 points each in the class. The application should receive the grades for each student and calculate the student’s average exam grade. According to the average, the application should display the student’s name and the letter grade for the class using the grading scheme below. Grading Scheme: •...
Create code In visual Basic, Windows forms that uses case statements to convert the day of...
Create code In visual Basic, Windows forms that uses case statements to convert the day of the week (entered by the user into an integer. (Sunday = 1, Monday = 2, etc.) For this code, think about error checking. What will your code do if the user enters “dog” for example (which is not a day of the week)? What will your code do if the user enters a number or other incorrect input?
how can i get the code for this problem in visual basic? Create a Windows Forms...
how can i get the code for this problem in visual basic? Create a Windows Forms applications called ISP (Internet Service Provider) Project. You must enter the number of hours for the month and select your desire ISP package. An ISP has three different subscription packages for it's customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2 per hours. Package B: For $13.95 per month 20 hours of access are provided. Additional...
How to make an application for windows using c# ?
How to make an application for windows using c# ?
I've created a C# Windows form application in Visual stuidos it allows the user to enter...
I've created a C# Windows form application in Visual stuidos it allows the user to enter information, save that information to a database, then show that information in a datagridview. Everything works fine but the datgridview. It shows that rows have been added but not the text. I can see in my database the reports that have been added so I know its alteast saving the information. I don't know what I'm doing wrong. Please help! My code: using System;...
must be written in c# using windows forms not console Scenario: Samediff bank has a 25-year...
must be written in c# using windows forms not console Scenario: Samediff bank has a 25-year old banking account system. It was created using procedural programming. Samediff bank needs to improve the security and maintainability of the system using an object-oriented programming (OOP) approach. Their bank manager has decided to hire you to develop, implement, and test a new OOP application using efficient data structures and programming techniques.Samediff banks manager is excited to consider updating their account system. An expert...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT