The following file has syntax and/or logical errors. In each case, determine the problem, and fix the program.
using System;
using static System.Console;
using System.IO;
class DebugFourteen1
{
static void Main()
{
string fileName;
string directory;
string path;
string files;
int x;
Write("Enter a directory: ");
directory = ReadLine();
if(Directory.Exists(Directory))
{
files = Directory.GetFiles(directory);
if(files.Length = 0)
WriteLine("There are no files in " + directory);
else
{
WriteLine(directory + " contains the following files");
for(x = 0; x <= files.Length; ++x)
WriteLine(" " + files[y]);
Write("\nEnter a file name: ");
fileName = ReadLine();
path = directory + "/" + fileName;
if(File.Exists(path))
{
WriteLine(" File exists and was created " +
File.GetCreationTime(path));
WriteLine("File was created " +
File.GetCreationTime(fileName));
}
else
WriteLine(" " + fileName + " does not exist in the " + directory, "
directory");
}
}
else
{
WriteLine("Directory " + directory + " does not exist");
}
}
}
Dear Student ,
As per requirement submitted above kindly find below solution.
Here new Windows Forms Application in C# is created using visual studio 2019 with name "DebugProgram".This application contains a class "DebugFourteen1.cs".Below are the details of this class.
DebugFourteen1.cs :
//namespace
using System;
using static System.Console;
using System.IO;
//application namespace
namespace DebugProgram
{
class DebugFourteen1 //C# class
{
//entry point main() method
static void Main(string[] args)
{
//declaring variables
string fileName;
string directory;
string path;
string[] files;
int x;
Write("Enter a directory: ");//asking user to enter directory
directory = ReadLine();//reading directory
//checking directory
if (Directory.Exists(directory))
{
files = Directory.GetFiles(directory);//get all directory
if (files.Length == 0)
//if directory doesnot exists
WriteLine("There are no files in " + directory);
else
{
//print directory
WriteLine(directory + " contains the following files");
for (x = 0; x < files.Length;x++) //using for loop
WriteLine(" " + files[x]);
Write("\nEnter a file name: ");//asking file name
fileName = ReadLine();//reading file
path = directory + "/" + fileName;
//checking file
if (File.Exists(path))
{
//if file exists
WriteLine(" File exists and was created " +
File.GetCreationTime(path));
WriteLine("File was created " +
File.GetCreationTime(fileName));//display time
}
else
//if file does not exists
WriteLine(" " + fileName + " does not exist in the " + directory, "
directory");
}
}
else
{
//if directory does not exits
WriteLine("Directory " + directory + " does not exist");
}
}
}
}
==================================
Output :Run application using F5 and will get the screen as shown below
Screen 1:

NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
The following file has syntax and/or logical errors. In each case, determine the problem, and fix...
The following file has syntax and/or logical errors. Determine the problem and fix the program. // Handles a Format Exception if user does not enter a number using System; using static Syst0em.Console; class DebugEleven1 { static void Main() { double salary; string salVal; bool isValidSalary; while(!isValidSalary) { try Write("Enter an employee's salary "); salVal = ReadLine(); salary = Convert.ToDouble(salVal); isValidSalary = true; catch(Formatexception fe) { WriteLine("You must enter a number for the salary."); } } WriteLine("The salary {0} is valid",...
C# Programming:
DebugNine2
The provided file has syntax and/or logical errors. Determine
the problem(s) and fix the program.
+DebugNine2.cs Instructions Build Output The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program. 1/ Creates a Breakfast class 2 // and instantiates an object 3// Displays Breakfast special information 4 using static System.Console; Conpilation fatled: 2 error(s), 8 warnings DebugNine2.cs(9,61): error C$1810: Newline in constant DebugNine2.cs (11,6): error CS1525: Unexpected synbol "Writeltne class DebugNine2 7static void...
The files provided contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. import java.util.*; public class DebugEight1 { public static void main(String args[]) { Scanner input = new Scanner(System.in); char userCode; String entry, message; boolean found = false; char[] okayCodes = {'A''C''T''H'}; StringBuffer prompt = new StringBuffer("Enter shipping code for this delivery\nValid codes are: "); for(int x = 0; x <...
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. Note: DebugDataOne1.txt and DebugDataOne2.txt do not need to be edited. They are used by the program. import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOException; public class DebugThirteen1 { public static void main(String[] args) { Path file1 = Paths.get("/root/sandbox/DebugDataOne1.txt"); // path to file DebugDataOne1.txt in...
In Chapter 11, you created the most recent version of the GreenvilleRevenue program, which prompts the user for contestant data for this year’s Greenville Idol competition. Now, save all the entered data to a Greenville.ser file that is closed when data entry is complete and then reopened and read in, allowing the user to view lists of contestants with requested talent types. The program should output the name of the contestant, the talent, and the fee. using System; using static...
Use a C# In previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing, Dancing, Musical instrument, and Other. Name these fields talentCodes and talentStrings respectively. The class contains an auto-implemented property Name that holds a contestant’s name. The class contains fields for a talent code (talentCode) and description (talent)....
Fix all syntax and logical errors for the following program. Please generate the correct output. // Program Typos prints three integer numbers, sums the numbers, calculates // the average, and prints the sum and the average of the three numbers. #Include #Include using namespace std; const ONE = 5; const TWO = 6; const THREE = 7; int Main () int sum; float average; cout << fixed << showpoint; c0ut << SetW(5) << ONE << TWO << THREE << end1;...
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. // Prompt user for value to start // Value must be between 1 and 20 inclusive // At command line, count down to blastoff // With a brief pause between each displayed value import java.util.*; public class DebugSix3 { public static void...
Using listAllFiles as a guide, write a method that has one File argument: if the argument is a directory, the method returns the total number of files below it. If the argument represents a file, the method just returns 1. public static int countFiles(File f) import java.io.File; public class FileLister { public static void main(String[] args) { // Choose the directory you want to list. // If running in Eclipse, "." will just be the current project directory. // Use...
The code will not run and I get the following errors in Visual Studio. Please fix the errors. error C2079: 'inputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' cpp(32): error C2228: left of '.open' must have class/struct/union (32): note: type is 'int' ): error C2065: 'cout': undeclared identifier error C2065: 'cout': undeclared identifier error C2079: 'girlInputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' error C2440: 'initializing': cannot convert from 'const char [68]' to 'int' note: There is no context in which this conversion is possible error...