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

I need help in finding the logical/syntax errors in this program: // Creates a H

ID: 3925958 • Letter: I

Question

I need help in finding the logical/syntax errors in this program:

// Creates a HomeworkAssignment class

// instantiates two objects

// and prompts the user for infromation about two courses using System;

class DebugNine1

{

static void Main() {

HomeworkAssignment course1 = new HomeworkAssignment();

HomeworkAssignment course2 = new HomeworkAssignment();

string entryString;

int exercises;

// Get info for first class

Console.Write("What class do you have homework for? ");

entry = Console.ReadLine();

course1.className = entryString;

Console.Write("How many exercises must you complete? ");

entryString = Console.ReadLine();

int.TryParse(entryString, exercises);

exercises = course1.NumberOfExercises;

// Get info for another class

Console.Write("What class do you have homework for? ");

entryString = Console.ReadLine();

course2.className = entrystring;

Console.Write("How many exercises must you complete? ");

entryString = Console.ReadLine();

char.TryParse(entryString, exercises);

course2.NumberOfExercises = exercises;

Console.WriteLine("You have {0} minutes of homework for {1}",

course1.timeToComplete, course1.ClassName); Console.WriteLine("and {0} more minutes for {1}", course2.timeToComplete,course2.ClassName);

}

}

class HomeworkAssignment

{

private int numberOfExercises;

private int timeToComplete;

// 10 minutes to complete each exercise

private const int TIME_PER_EXERCISE = 10;

public ClassName {get; set};

public int NumberOfExercises;

{

get

{

return numberOfexercises;

}

set

{

numberOfExercises = number;

CalcCompletionTime();

}

}

public double TimeToComplete

{

get

{

return timeToComplete;

}

}

private void CalcCompletionTime()

{

timeToComplete = numberOfExercises * TIME_PER_EXERCISE;

}

}

Explanation / Answer

1) You havent initiated "Entry" string before using it in entry = Console.ReadLine();

2)In ourse1.className = entryString; , you need to instantiate the class name using constructor for the class and the nuse getCLassname() and setClassname() functions and inside that you need to write return class name .

3)char.TryParse(entryString, exercises) , in this you havent written the metod definition for tryparse method anywhere in the program

4) You took the same string for number of exercises and class having homework . Both should have different string names

5)

private int numberOfExercises;

private int timeToComplete; access specifiers should not be praivate as they cannot be accessed by other parts of the program if they are priavate .Please make them public

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