Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - Square, Tube, Bike

aly
aly 


(1): Square. Write a program that meets the following requirements: Square Class 1. Create a class called Square which has the following instance variables (do NOT add any other instance variables to the class): - Length of sides (private double length;) 2. Create the constructor which receives the length of the sides as a parameter 3. Write the getter and setter methods for the instance variable 4. Override the toString method by using the following code @Override public String toString() { String value = "Length is " + length; return value; } 5. Write a method to compute the area of the square 6. Write a method to compute the perimeter of the square 7. Write a method to compute the length of the diagonal using the Pythagorean theorem There should be NO main method in the Square class. SquareTester Class: - 1. Create a class called SquareTester which constructs 5 different Square objects 2. For each Square object you created, SOP the object, its area, perimeter, and length of the diagonal. ………………………………………………………………………………………………………………………… (2): Tube Write a program that meets the following requirements: Tube Class 1. Create a class called Tube which has the following instance variables (do NOT add any other instance variables to the class): - Height of tube - Diameter of tube 2. Create the constructor which receives the height and diameter as parameters 3. Write the getter and setter methods for each instance variable 4. Override the toString method (using the same pattern as above). Be sure to include both instance variables in the String returned. 5. Write a method to compute the volume of the cylindrical tube 6. Write a method to compute the surface area of the cylindrical tube There should be NO main method in the Tube class. TubeTester Class:- 1. Create a class called TubeTester which constructs 5 different Tube objects 2. For each Tube object you created, SOP the object, its volume, and surface area. ………………………………………………………………………………………………………………………… (3): Bike Write a program that meets the following requirements: Bike Class 7. Create a class called Bike which has the following instance variables: - Number of wheels - Diameter of tires - Manufacturer name - Year built 8. Create the no-argument constructor 9. Create the constructor which uses all fields as parameters 10. Write the getter and setter methods for all instance variables 11. Override the toString method using the example shown above There should be NO main method in the Bike class. BikeTester Class:- 3. Create a class called BikeTester which constructs 10 different Bike objects 4. Add each Bike object to an array 5. Use a for loop to SOP each Bike reference Attachments
Tags Clarifications

Answers

Solution

mariobeka
mariobeka 



You will find three project with the name of each exercise. Which contains the solution of each one. Attachments
Square.zip (3 K) Download




Preview
double diagonal() { return Math.sqrt((length * length) + (length * length)); } public double getLength() { return length; } public void setLength(double length)

Preview
square2 = new Square(10); Square square3 = new Square(30); Square square4 = new Square(1.5); Square square5 = new Square(20.1);

Tube.zip (3 K) Download




Preview
* height; } public double getHeight() { return height; } public void setHeight(double height) { this.height = height; } public double getDiameter() { return diameter; } public void setDiameter(double diameter) { this.diameter

Preview
{ public static void main(String[] args) { Tube tube1 = new Tube(1,4); Tube tube2 = new Tube(4,2);

Bike.zip (3 K) Download




Preview
this.diameter = diameter; this.name = name; this.year = year; } public int getNr_wheels() { return nr_wheels; } public void setNr_wheels(int nr_wheels) { this.nr_wheels = nr_wheels; } public double getDiameter() { return diameter; } public void setDiameter(double diameter) { this.diameter = diameter;

Preview
1990), new Bike(3, 10.2, "HP", 1880), new Bike(7, 4.1, "Apple", 2000), new Bike(4, 4, "Dell", 2002), new Bike(6, 5, "Beats", 2011),

Screenshots
Purchase Answer

Square Project

SW_wizard
SW_wizard 



Complete code for Square project Attachments
Square.java (1 K) Download Preview
double perimeter; perimeter = 4 * length; return perimeter; } //7. method to compute the length of the diagonal using the Pythagorean theorem public double lengthOfDiagonal(){ //formula is: diagonal = sqrt(length^2 + length^2) double diagonal = Math.sqrt(Math.pow(length,2) + Math.pow(length,2));

SquareTester.java (2 K) Download Preview
System.out.println("Area of square = "+ area); System.out.println("Perimeter of square = "+ perimeter); System.out.println("Length of square = "+ diagonal+"\n\n"); //for fifth square object area = sq5.areaOfSquare(); perimeter = sq5.perimeterOfSquare(); diagonal = sq5.lengthOfDiagonal(); System.out.println(sq5.toString()); System.out.println("Area of square = "+ area); System.out.println("Perimeter

Screenshots
Purchase Answer

Clarification of SOP

mariobeka
mariobeka 



SOP stands for System.out.println Attachments
Screenshots
Purchase Answer

Complete Bike Project

mariobeka
mariobeka 



I'm posting this project for everyone who is missing just a part of the Assignment! Attachments
Bike.zip (3 K) Download




Preview
{ return nr_wheels; } public void setNr_wheels(int nr_wheels) { this.nr_wheels = nr_wheels; } public double getDiameter() { return diameter; } public void setDiameter(double diameter) { this.diameter = diameter; } public String getName() { return name; } public void setName(String name) {

Preview
new Bike(6, 5, "Beats", 2011), new Bike(8, 9.2, "Philips", 2003), new Bike(9, 6.2, "Esprit", 1771), new Bike(10, 8.3, "Michelin", 1823), new

Screenshots
Purchase Answer