[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 same variable names in the parameter list. Assign each variable to numberOfWheels” and “weight” respectively. Write a separate application to test the class and display its properties. Note: Do not change the names of the instance variables or the variables listed in the constructor’s parameter list. [B] Edit your class Cycle by adding a default constructor which will assign the default values of 100 to represent the numberOfWheels, and 1000 to represent the weight, by invoking a call to the other constructor. Modify your application created in [A] to test the class. Directions [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 existing constructor 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. Display the properties of the object.
JAVA Programming Problem 2 - 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 same variable names in the parameter list. Assign each variable to numberOfWheels” and “weight” respectively. Write a separate application to test the class and display its properties. Note: Do not change the names of the instance variables or the variables listed in the constructor’s parameter list.
[B] Edit your class Cycle by adding a default constructor which will assign the default values of 100 to represent the numberOfWheels, and 1000 to represent the weight, by invoking a call to the other constructor. Modify your application created in [A] to test the class.
Directions
[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 existing constructor 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.
- Display the properties of the object.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 7 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Programming Problem 3 – CycleFileInput
Revisit the Cycle class in Module 3. Modify your application such that the properties will be read from a text file called “Cycle.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.
Programming Problem 1 – CycleThrowTryCatch
Revisit the Cycle class in Module 3. Modify your application such that the properties, numberOfWheels and weightare 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.
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)