Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: FIX THE ERRORS , BUT ONLY USING C#, PLEASE there are 3 separate and differen codes please dont mi... FIX THE ERRORS , BUT

Question: FIX THE ERRORS , BUT ONLY USING C#, PLEASE there are 3 separate and differen codes please dont mi...

FIX THE ERRORS , BUT ONLY USING C# ONLY, PLEASE

there are 3 separate and differen codes please dont mix them

a)

// Overloaded method gives bonus points // whether grade is a number or letter using static System.console; class DebugEight2 { Static Void Main() { int numericScore = 0; Do { Try { Write("What is the score? "); numericScore = Convert.ToInt32(ReadLine()); } Catch { Write("Bad format for score. Try again. What is the score? ") } } While(bad)

string letterScore = ""; Write("What is the score's letter grade? ?); letterScore = ReadLine();

Write("Score was {0}. ", numericScore); GiveBonus(ref numericScore); WriteLine("Now it is {0}.", numericScore); Write("Grade was ", letterScore); GiveBonus(ref letterScore); WriteLine("Now it is ", letterScore); } private static void GiveBonus(int ref testScore) { const int BONUS = 5; testScore = BONUS; } private static void GiveBonus(string ref letterScore) { const string BONUS = "+"; letterScore = BONUS; } }

b)

// 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(); 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 {1} minutes of homework for {2}", course1.timeToComplete, course1.ClassName); WriteLine("and {1} more minutes for {2}", 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; } }

c)

// Creates a Breakfast class // and instantiates an object // Displays Breakfast special information using static System.Console; class FixedDebugNine2; { static void Main() { Breakfast special = new Breakfast("French toast, 4.99); //Display the info about breakfast WriteLine(INFO); // then display today's special WriteLine("Today we are having {0} for {1}", special.name, special.Price.ToString("C2")); } } class Breakfast { public string INFO = "Breakfast is the most important meal of the day."; Private string name; Private double Price; // Breakfast constructor requires a // name, e.g "French toast", and a price public Breakfast(string name, double price) { name = name; price = price; } public string Name {get; set} public double Price {get; set} }

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

7. Explain why retirees may be valuable as part-time employees.

Answered: 1 week ago

Question

3. Provide advice on how to help a plateaued employee.

Answered: 1 week ago