Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program. // Creates a HomeworkAssignment class // instantiates two objects //

The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program.

// Creates a HomeworkAssignment class

// instantiates two objects

// and prompts the user for infromation about two courses

using static System.Console;

class DebugNine1

{

static void Main()

{

HomeworkAssignment course1 = new HomeworkAssignment();

HomeworkAssignment course2 = new HomeworkAssignment();

string entryString;

int exercises;

// Get info for first class

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

entry = ReadLine();

course1.className = entryString;

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

entryString = ReadLine(entry);

int.TryParse(entryString, exercises);

exercises = course1.NumberOfExercises;

// Get info for another class

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

entryString = ReadLine();

course2.className = entrystring;

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

entryString = ReadLine();

char.TryParse(entryString, exercises);

course2.NumberOfExercises = exercises;

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

course1.timeToComplete, course1.ClassName);

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;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions