Please help me this problem. Provide the design and codes withpictures also separate answer
Thank you
WE WRITE PAPERS FOR STUDENTS
Tell us about your assignment and we will find the best writer for your project
Write My Essay For MeRandom Number File Reader This exercise assumes you have completed Programming Problem 13, Randorm Number File Writer. Create another application that uses an OpenFileDialog con- trol to let the user select the file that was created by the application that you wrote for Problem 13. This application should read the numbers from the file, display the numbers in a ListBox control, and then display the following data: . The total of the numbers . The number of random numbers read from the file 14. Show transcribed image text Random Number File Reader This exercise assumes you have completed Programming Problem 13, Randorm Number File Writer. Create another application that uses an OpenFileDialog con- trol to let the user select the file that was created by the application that you wrote for Problem 13. This application should read the numbers from the file, display the numbers in a ListBox control, and then display the following data: . The total of the numbers . The number of random numbers read from the file 14.
Expert Answer
Dear Student ,
As per the requirement submitted above , kindly find the belowsolution.
Here a new Windows Forms Applicationin C# is created using Visual Studio 2017 with name”Demo_RandomNumberFileReader“.This applicationcontains a form with name “Form1.cs“.Below are thefiles associated with form1.
1.Form1.cs[Design]
2.Form1.Designer.cs
namespace Demo_RandomNumberFileReader
{
partial class Form1
{
///
///
private System.ComponentModel.IContainer components = null;
///
///
/// true if managed resources shouldbe disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.lstRandomNumbers = new System.Windows.Forms.ListBox();
this.lblNumbers = new System.Windows.Forms.Label();
this.btnReadFile = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lstRandomNumbers
//
this.lstRandomNumbers.FormattingEnabled = true;
this.lstRandomNumbers.Location = new System.Drawing.Point(12,26);
this.lstRandomNumbers.Name = “lstRandomNumbers”;
this.lstRandomNumbers.Size = new System.Drawing.Size(116,186);
this.lstRandomNumbers.TabIndex = 0;
//
// lblNumbers
//
this.lblNumbers.AutoSize = true;
this.lblNumbers.Location = new System.Drawing.Point(159, 39);
this.lblNumbers.Name = “lblNumbers”;
this.lblNumbers.Size = new System.Drawing.Size(0, 13);
this.lblNumbers.TabIndex = 1;
//
// btnReadFile
//
this.btnReadFile.Font = new System.Drawing.Font(“Microsoft SansSerif”, 12F, System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnReadFile.Location = new System.Drawing.Point(162,150);
this.btnReadFile.Name = “btnReadFile”;
this.btnReadFile.Size = new System.Drawing.Size(152, 36);
this.btnReadFile.TabIndex = 2;
this.btnReadFile.Text = “&Click to Read File”;
this.btnReadFile.UseVisualStyleBackColor = true;
this.btnReadFile.Click += newSystem.EventHandler(this.btnReadFile_Click);
//
// btnExit
//
this.btnExit.Font = new System.Drawing.Font(“Microsoft Sans Serif”,12F, System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnExit.Location = new System.Drawing.Point(162, 192);
this.btnExit.Name = “btnExit”;
this.btnExit.Size = new System.Drawing.Size(152, 26);
this.btnExit.TabIndex = 3;
this.btnExit.Text = “E&xitrn”;
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += newSystem.EventHandler(this.btnExit_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(336, 230);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnReadFile);
this.Controls.Add(this.lstRandomNumbers);
this.Controls.Add(this.lblNumbers);
this.Name = “Form1”;
this.Text = “Random Number File Reader”;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListBox lstRandomNumbers;
private System.Windows.Forms.Label lblNumbers;
private System.Windows.Forms.Button btnReadFile;
private System.Windows.Forms.Button btnExit;
}
}
3.Form1.cs
//namespace
using System;
using System.Windows.Forms;
using System.IO;
//application namespace
namespace Demo_RandomNumberFileReader
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Read file button clcik
private void btnReadFile_Click(object sender, EventArgs e)
{
//creating object of open file dialog
OpenFileDialog fileDialog = new OpenFileDialog();
//display dialog
fileDialog.ShowDialog();
//selected file path
string Path = fileDialog.FileName;
//creating object of stream reader
StreamReader reader = new StreamReader(Path);
string lineFromFile = “”;
//declaring variables
int sumofNumbers = 0;
int totalNumbers = 0;
while ((lineFromFile = reader.ReadLine()) != null)
{
//add number in the listbox
lstRandomNumbers.Items.Add(lineFromFile);
//calculate sum
sumofNumbers = sumofNumbers + int.Parse(lineFromFile);
//increment count
totalNumbers++;
}
//display sum and number count on the label
lblNumbers.Text = “Total Numbers are ” + totalNumbers +Environment.NewLine + “Sum of Numbers are :” + sumofNumbers;
}
//Exit button click
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();//close application
}
}
}
Screen for code :
======================================================
Output : Run application using F5 and will getthe screen as shown below
Screen 1 :
Screen 2 :Screen showing open file dialog
Screen 3:Screen showing total numbers and sumof numbers
Screen 4 :Sample.txt
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THESOLUTION.
一口 Random Number File Reader × Click to Read File Exit Demo_RandomNumberFileReader Demo RandomNumberFileReader.Form1 btnReadFile Click(object sender, EventArs 1 reference private void btnReadFile Click (object sender, EventArgs e) 15 16 17 18 //creating object of open file dialog OpenFileDialog fileDialog- new OpenFileDialog); //display dialog fileDialog.ShowDialog); //selected file patih string Path-fileDialog.FileName //creating object of stream reader StreamReader reader new StreamReader(Path) string lineFromFile //declaring variables int sumofNumbers e; int totalNumbers e; while ((lineFromFile -reader.ReadLine()) null) 20 21 23 24 25 27 28 29 30 31 32 //add number in the listbox 1stRandomNumbers.Items.Add(lineFromFile); //calculate sum sumofNumbers sumofNumbers + int.Parse(11neFromFile); //increment count totalNumbers++; 35 36 37 38 //display sum and number count on the label lblNumbers . Text = “Total Numbers are ” + totalNumbers + Environment.NewLine + “Sum of Numbers are :” + sumofNumbers; 40 41 //Exit button click 1 reference private void btnExit Click (object sender, EventArgs e) 42 43 Application.Exit);//close application 45 100 % Error List Data Tools Operations Output 一口 Random Number File Reader × Click to Read File Exit Open This PC Desktop vSearch Desktop Organize▼ New folder pnpiviyaamin pvtnoniviain pytnoniviaini Quick access Desktopメ Downloads 囹Documents pythonMain2 pythonMain3 randomNumbers Pictures Morning Mantra Old Songs Sairat Video SQL Server Mana twoDsum USerlnfo sample OneDrive This PC File name: sample Open Cancel Random Number File Reader 41 43 Total Numbers are 2 Sum of Numbers are:84 Click to Read File Exit sample-Notepad File Edit Format View Help 41 43
I lOVE this Professional essay writing website. This is perhaps the fifth time I am placing an order with them, and they have not failed me not once! My previous essays and research papers were of excellent quality, as always. With this essay writing website, you can order essays, coursework, projects, discussion, article critique, case study, term papers, research papers, research proposal, capstone project, reaction paper, movie review, speech/presentation, book report/review, annotated bibliography, and more.
Post your homework questions and get original answers from qualified tutors!