I'm trying to do this in a C# Console App.(NET Framework).I've attached the Code that will be required to complete. Any Guidance will be appreciated.
C# Console File I/O Project Assignment
Working with files and being able to process data in and out of a file is critical to the programmer’s role. Almost every organization will have to deal with files one way or another. For example, it is very common for accountants to use spreadsheets for calculations and sometimes you are called to help them with their data problems.
This assignment helps you become familiar with handling files and processing data between the program and the file. Review the project requirements below and use the sample C# source code to get you started. While reading the source code you will find some of the problems and during runtime, you will find more issues. The source code is not broken and it works within a C# console program. The main objective of this week’s assignment is to fix the source code and make the code perform more efficiently.
File I/O Console Program Requirements:
try
{
//https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-read-from-a-text-file
//https://www.c-sharpcorner.com/UploadFile/mahesh/create-a-text-file-in-C-Sharp/
if
(!System.IO.File.Exists(@"C:\Users\terry.brookhouser\Desktop\data2.txt"))
{
System.IO.File.Create(@"C:\Users\terry.brookhouser\Desktop\data2.txt");
}
using (System.IO.StreamWriter file = new
System.IO.StreamWriter(@"C:\Users\terry.brookhouser\Desktop\data2.txt",
true))
{
file.WriteLine("Welcome Students!!!!");
file.WriteLine("As we are learning about new C# programming
features.");
file.WriteLine("You should be having lots of fun in this
class.");
}
string Path =
System.IO.File.ReadAllText(@"C:\Users\terry.brookhouser\Desktop\data2.txt");
Console.WriteLine(Path);
Console.ReadKey();
}
catch (Exception em)
{
Console.WriteLine("An error occured: " + em.Message);
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileOper
{
class Program
{
static void Main(string[] args)
{
string filepath = "";
string choice = "";
string filename = "";
try
{
do
{
Console.WriteLine("1) Load file");
Console.WriteLine("2) Create file");
Console.WriteLine("3) Exit");
Console.Write("Enter option : ");
choice = Console.ReadLine();
if (choice == "1")
{
Console.Write("Enter the file path : ");
filepath = Console.ReadLine();
if (!Directory.Exists(filepath))
{
Directory.CreateDirectory(filepath);
}
filepath = filepath.EndsWith(@"\") ? filepath : filepath +
@"\";
Console.Write("Enter valid text file name with ext for load :
");
filename = Console.ReadLine();
if (File.Exists(filepath + filename.Trim()))
{
Console.WriteLine(File.ReadAllText(filepath +
filename.Trim()));
}
else
{
Console.WriteLine("file not found");
}
}
else if (choice.Equals("2"))
{
Console.Write("Enter the file path :");
filepath = Console.ReadLine();
if (!Directory.Exists(filepath))
{
Directory.CreateDirectory(filepath);
}
filepath = filepath.EndsWith(@"\") ? filepath : filepath +
@"\";
Console.Write("Enter text file name with ext for create: ");
filename = Console.ReadLine();
using (System.IO.StreamWriter file = new
System.IO.StreamWriter(filepath + filename.Trim(), true))
{
file.WriteLine("Welcome Students!!!!");
file.WriteLine("As we are learning about new C# programming
features.");
file.WriteLine("You should be having lots of fun in this
class.");
}
Console.WriteLine("File saved with default text : "+ filepath +
filename.Trim());
}
} while (!choice.Equals("3")); // exit on 3
}
catch (Exception ex)
{
Console.WriteLine("An error occured: " + ex.Message);
}
}
}
}
I'm trying to do this in a C# Console App.(NET Framework).I've attached the Code that will...
Fix program errors and improve code Visual Studio C# Console App (.NET Framework) Task The program must allow for the teacher to either enter a predetermined number of scores (e.g. 10 exam scores), to keep allowing them to enter in scores until they are finished. You will need to convert these scores to a percentage then store these in a list. You will perform some calculations on these results and also display the contents of the list (percentage values) back...
C++ programming help.
The only change you have to make is in current program,
where it says "your code goes here", do not make any changes to any
other files, they are just there to show you. This
code should be written for arbitrary data, not specifically for
this sequence of data. The only place you need to
write a code is marked YOUR CODE GOES HERE.
You have been supplied a file with data in it (data2.txt). The
line...
This assignment tests your ability to write C programs that handle keyboard input, formatted console output, and input/output with text files. The program also requires that you use ctype functions to deal with the logic. In this program, you will input from the user two characters, which should both be letters where the second letter > the first letter. You will then input a file character-by-character and output those letters that fall between the two characters (inclusively) to an output...
I need help finding the error in my code for my Fill in the Blank (Making a Player Class) in C++. Everything looks good to me but it will not run. Please help... due in 24 hr. Problem As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. Currently, there is a test...
;
I'm having an issue editing the code. Could you please edit the
code as the tutorial states and past the console output.
Here is the link.
https://docs.microsoft.com/en-us/visualstudio/debugger/quickstart-debug-with-cplusplus?view=vs-2017
Exercise 1: Visual Studio Debugger https://docs.microsoft.com/en-us/visualstudio/debugger/quickstart-debug-with- cplusplus?view=vs-2017 Complete the tutorial. Include the console output of the sample console program after editing the code while debugging. The green Continue toolbar button can be used to continue executing code after pausing from a breakpoint. Instead of pressing F10, you can "Step Over" code using...
Assignment 11 – Exceptions, Text Input/Output - Random Numbers Revised 9/2019 Chapter 12 discusses Exception Handling and Input/Output. Using try/catch/finally statement to handle exceptions, or declare/throw an exception as needed, create the following program: Create an array of 25 random numbers between 0 & 250 formatted to a field width of 10 & 4 decimal places (%10.4f). Use the formula Math.random() * 250. Display the array of random numbers on the console and also write to a file. Prompt the...
project: c++ code with output
Phonebook Management System C++ Phonebook management system project in C++ is a simple console application built without graphics. In this project, users can add a new phone record, display existing phone records, search a particular phone record and delete phone records. This simple project will teach you file handling operations such as how to add, search, modify, list and delete records using file. Use header Files for separate compilation. Features: 1. Add phone record: 2....
Please write this in C.
Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...
I need some help with programming this assignment.
Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to write a Python class Be able to define class attributes Be able to define class methods .Be able to process input from a text file .Be able to write an application using objects The goal of this programming assignment is to develop a simple image processing application. The application will import a class that creates image objects with...
Write c program. Do part 4 and 5
CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should have the following format: by Columns 1-4 6-8 number of a student A grade out of 100 EYERCISE 12-4 Write a program that will read the identification numbers of students and their letter grades (A, B, C, D, or F) from the keyboard and store them in a text file...