
Computer Science
Need Debugging following these guidelines:
program produces correct output
Fixed bug(s) in Car class
// Creates a Car class
// You can construct a Car using a price and color
// or just a price, in which case a Car is black
// or no parameters, in which case a Car is $10,000 and black
using System;
using static System.Console;
using System.Globalization;
class DebugNine3
{
static void Main()
{
Car myCar = new Car(32000, "red");
Car yourCar = new Car(14000);
Car theirCar;
WriteLine("My {0} car cost {1}", myCar.color,
myCarr.Price.ToString("c2", CultureInfo.GetCultureInfo("en-US")));
WriteLine("Your {0} car cost {1}",
yourCar.Color, youRCar.price.Tostring("c2", CultureInfo.GetCultureInfo("en-US")));
WriteLine("Their {0} car cost {1}",
theirCar.Color, theirCar.price.ToString("c2", CultureInfo.GetCultureInfo("en-US")));
}
}
class Car
{
private string color;
private int price;
public Car() : this(10000, "black")
{
}
public Car(int price) : this()
{
}
public Car(int price, string color)
{
Price = this;
Color = color;
}
public string Color
{
get
{
return color;
}
set
{
color = value;
}
}
public int Price
{
get
{
return Price;
}
set
{
price = value;
}
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images

- using System;public static class Lab3_2{public static void Main(){// declare the variables and constantsconst double FLAT = 1.25;double weight;double cost, pricePerKg = 0;// Input the weightConsole.Write("Enter a positive weight of the package => ");weight = Convert.ToDouble(Console.ReadLine());// Determine the cost per kilogramif (weight <= 0)Console.WriteLine("*** Invalid weight");else if (weight < 1)pricePerKg = 0.25;else if (weight <= 3.5)pricePerKg = 0.5;else (weight > 3.5)pricePerKg = 1.0;// Compute the cost to send the packageif (weight > 0)cost = weight * pricePerKg + FLAT;elsecost = 0;// Output the resultsConsole.WriteLine("The cost to send the package is {0:C}",cost);Console.ReadLine();}} Remove the error from the given program and run it for input weight 2.5.arrow_forwardpublic static class Lab2{public static void Main(){int idNum;double payRate, hours, grossPay;string firstName, lastName;// prompt the user to enter employee's first nameConsole.Write("Enter employee's first name => ");firstName = Console.ReadLine();// prompt the user to enter employee's last nameConsole.Write("Enter employee's last name => ");lastName = Console.ReadLine()// prompt the user to enter a six digit employee numberConsole.Write("Enter a six digit employee's ID => ");idNum = Convert.ToInt32(Console.ReadLine());// prompt the user to enter the number of hours employeeworkedConsole.Write("Enter the number of hours employee worked =>");// prompt the user to enter the employee's hourly pay rateconsole.Write("Enter employee's hourly pay rate: ");payRate = Convert.ToDouble(Console.ReadLine());// calculate gross paygrossPay = hours * payRate;// output resultsConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3}",firstName, lastName, idNum,…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





