Question: Programming Problem 1 CycleThrowTryCatch Revisit the Cycle class in Unit 3.10.1. Modify your application such that the properties, numberOfWheels and weight are entered as double
Programming Problem 1 CycleThrowTryCatch Revisit the Cycle class in Unit 3.10.1.
Modify your application such that the properties, numberOfWheels and weight are entered as double values interactively (at the keyboard). Exception handling will be used to determine whether a type mismatch occurs. Edit your application such that, in addition to [A], the values for numberOfWheels and weight, entered interactively, will throw a new exception Values cannot be less than or equal to zero only If the values are less than or equal to zero. Add or use the appropriate try and/or catch blocks.
Directions Examine your application for the class called Cycle.
Add Try and Catch blocks appropriately.
Add the throw statement for the new exception.
Display an appropriate message if an exception occurs.
Display the properties of the object. Note: Verify the contents were written to the text file using notepad (or any word processor).
Grading Rubric:
Try and Catch blocks added correctly 1
Appropriate message used for each exception 1
Throw statements used correctly 1
Object properties displayed correctly 1
Proper documentation 1
Program works effectively 1
Programming Problem 2 CycleFileOutput Revisit the Cycle class in Unit 3. Modify your application such that the properties will be written to a text file called CycleOut.txt instead of to the screen.
Directions Examine your application for the class called Cycle.
Add an appropriate throws statement in the main method.
Create a reference to a File class with the appropriate name of a text file (Cycle.txt).
Use appropriate code to ensure that the text file exist.
Output the values of the variables to the text file.
Close the file. Note: Verify the contents were written to the text file using notepad (or any word processor).
Grading Rubric
Throws clause added in main method 1
Create a reference to the File class and text file 1
Check whether the text file exists 1
Output the properties to the text file 1
Close the text file 1
Proper documentation 1
Program works effectively 1
Programming Problem 3 CycleFileInput
Revisit the Cycle class in Unit 3. Modify your application such that the properties will be read from a text file called CycleIn.txt.
Directions Examine your application for the class called Cycle.
Add an appropriate throws statement in the main method.
Create a reference to a File class with the appropriate name of a text file (Cycle.txt). Note: Cycle.txt was created in the previous assignment, CycleFileOutput.
In your code, check that the text file does exist.
Input the values from the file to memory.
Close the file.
Grading Rubric
Throws clause added in main method 1
Create a reference to the File class and text file 1
Check whether the text file exists 1
Read the properties from the text file and output to screen 1
Close the text file 1
Proper documentation 1
Program works effectively 1
Previous Problem - Cycle
[A] Create a class called Cycle which has two instance integer variables as properties,numberOfWheels and weight. Create a constructor with two parameters, using the samevariable names in the parameter list. Assign each variable to numberOfWheels and weightrespectively. Write a separate application to test the class and display its properties. Note: Donot change the names of the instance variables or the variables listed in the constructorsparameter list.
[B] Edit your class Cycle by adding a default constructor which will assign the default values of100 to represent the numberOfWheels, and 1000 to represent the weight, by invoking a call tothe other constructor. Modify your application created in [A] to test the class.
[A] Create a class called Cycle
Declare integer instance variables numberOfWheels and weight as private.
Include a toString() method in the Cycle class. No set or get methods are included.
Create a constructor with two parameters, using the same variable names numberOfWheels and weight in the parameter list. Complete the constructor as necessary.
Create a separate application to test the class.
Create an object of the Cycle class.
Display the properties of the object.
[B] Add a default constructor
Edit the default constructor such that the default constructor will invoke the existingconstructor with the default values of 100 to represent the numberOfWheels, and 1000 to represent the weight.
Invoke the constructor using the this reference.
Create the second constructor which will receive the two arguments.
Create a separate application to test the class.
Create an object of the Cycle class.o Display the properties of the object.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
