Cannot figure out why these arent working. PROBLEM 1: using System; public class
ID: 3657294 • Letter: C
Question
Cannot figure out why these arent working. PROBLEM 1: using System; public class DebugSeven1 { public static void Main() { HomeworkAssignment course1; HomeworkAssignment course2; string entryString; int exercises; // Get info for first class Console.Write("What class do you have homework for? "); entryString = ConsoleReadLine(); course1.ClassName = entryString; Console.Write("How many exercises must you complete? "); entryString = Console.readLine(); exercises = Convert.ToInt(entryString); course1.NumberOfExercises() = exercises; // Get info for another class Console.Write("What class do you have homework for? "); entryString = Console.ReadLine(); course1.ClassName = entrystring; Console.Write("How many exercises must you complete? "); entryString = Console.Readline(); exercises = Convert.ToInt(entryString); course1.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, course3.ClassName); } } class HomeworkAssignment { private string className; private int numberOfExercises; private int timeToComplete; // 10 minutes to complete each exercise private const int TIME_PER_EXERCISE = 10; public string ClassName {get, set} public int NumberOfExercises { get { return numberOfExercises; } set { NumberOfExercises = numberOfExercises; CalcCompletionTime(); } } public double TimeToComplete { get { return timetoComplete; } } private void CalcCompletionTime() { timeToComplete = numberOfExercises + TIME_PER_EXERCISE; } } PROBLEM 2: // 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; public class DebugSeven3 { public static void Main() { Car myCar = Car("red", 32000); Car yourCar = Car(14000); Car theirCar = Car(); Console.WriteLine("My {0} car cost {1}", myCar.Color, myCar.Price.ToString(c2)); Console.WriteLine("Your 0} car cost {1}", yourCar.Color, yourCar.Price.ToString("c2")); Console.WriteLine("Their {0} car cost {1}", theirCarColor, theirCar.price.ToString("c2")); } } class Car { private string color; private int price; public Car() : this(10000, "black") { } public Car(int price) : this("black") { } public Car(int price, string color) { price = Price; Color = color; } public string Color { get { return color; } set { color = value; } } public int Price { get { return price; } set { price = value2; } } }Explanation / Answer
//cramster dont allow multiple questions in one post //so post the problem 2 again and give me the link //answer for program 1 ....pls rate import java.util.*; public class DebugSeven1 { public static void main(String args[]) { HomeworkAssignment course1 = new HomeworkAssignment(); HomeworkAssignment course2 = new HomeworkAssignment(); String entryString; int exercises; Scanner s = new Scanner(System.in); // Get info for first class System.out.println(); System.out.println("What class do you have homework for? "); entryString = s.nextLine(); course1.ClassName = entryString; System.out.println("How many exercises must you complete? "); entryString = s.nextLine(); exercises = Integer.parseInt(entryString); course1.setNumberOfExercises(exercises); System.out.println(); // Get info for another class System.out.println("What class do you have homework for? "); entryString = s.nextLine(); course2.ClassName = entryString; System.out.println("How many exercises must you complete? "); entryString = s.nextLine(); exercises = Integer.parseInt(entryString); course2.setNumberOfExercises(exercises); System.out.println(); System.out.println("You have "+course1.getTimeToComplete()+" minutes of homework for "+course1.ClassName); System.out.println("You have "+course2.getTimeToComplete()+" minutes of homework for "+course2.ClassName); } } class HomeworkAssignment { public String ClassName; private int NumberOfExercises; private double timeToComplete; // 10 minutes to complete each exercise private int TIME_PER_EXERCISE = 10; public HomeworkAssignment() { } public int getNumberOfExercises() { return NumberOfExercises; } public void setNumberOfExercises (int numberofExercises) { NumberOfExercises = numberofExercises; CalcCompletionTime(); } public double getTimeToComplete() { return timeToComplete; } private void CalcCompletionTime() { timeToComplete = NumberOfExercises * TIME_PER_EXERCISE; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.