Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

CSE110 - Arizona State University

Topics
- Conditional and Loops (Chapter 4)
- Implementing classes (Chapter 5)
- Understanding and accessing instance variables (Chapter 8)
- Implementing methods (Chapter 6)
- Object construction (Chapter 6)
- Constructors (chapter 8)
- Encapsulation (Chapter 8)

Coding Guidelines:
- Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc).
- Keep identifiers to a reasonably short length.
- User upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects).
- Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent.
- Use white space to make your program more readable.

Part #1: Written Exercises
None

Part #2 - Programming
Your assignment is to write a class definition (not a program, there is no main method) named Triangle
(saved in a file Triangle.java). A Triangle has 3 instance variables:
int side1, side2, side3;

The class Triangle must include the following constructors and methods: (If your class does not contain any of the following methods, points will be deducted).
- public Triangle (int s1, int s2, int s3) - Sets up a triangle with the specified side lengths.
- private int largest() - Returns the length of the longest side of the triangle. This is a helper method.

- private int shortest() Returns the length of the shortest side of the triangle. This is a helper method.
- public boolean is_equilateral() - Determines whether a triangle is equilateral. If the longest side is equal to the shortest side, then the triangle is equilateral.
- public boolean is_isosceles() - Determines whether a triangle is isosceles. Any (and at least) two sides must be equal.
- public boolean is_scalene() - Determines whether a triangle is scalene. No two sides are equal.
- public String toString() - Prints the sides of the triangle.
Save the Triangle class in a file called Triangle.java and use the following program stored in Assignment4.java which has the main method to create a new Triangle object and to test what kind of Triangle it is. A sample output is shown below.

Important
Your class should have exactly the method headers that are described or otherwise your class will not work with the test driver program (Assignment4.java) that is provided. You should never change the test driver program if the test driver is provided but instead make changes to Triangle class to make it work.

Helpful Hints
- Work on it in steps - write one method, test it with a test driver and make sure it works before going on to the next method.
- Always make sure your code compiles before you add another method.
- Your methods should be able to be called in any order.
Triangle equal = new Triangle (6, 6, 6); //example of equilateral (and isosceles) triangle Triangle isosceles = new Triangle (3, 7, 7); // example of isosceles triangle
Triangle scalene = new Triangle (4, 5, 6); // example of scalene triangle

Sample Outputs
Sample 1:
Enter the sides of the triangle:
3 4 5
3 4 5 triangle:
It is not isosceles
It is not a equilateral It is scalene

Check another Triangle (y/n)? y
Enter the sides of the triangle:
4 5 6
4 5 6 triangle:
It is not isosceles
It is not a equilateral It is scalene

Check another Triangle (y/n)? y
Enter the sides of the triangle:
4 4 4

4 4 4 triangle: It is isosceles It is equilateral
It is not scalene

Check another Triangle (y/n)? y
Enter the sides of the triangle:
3 7 7
3 7 7 triangle: It is isosceles
It is not a equilateral It is not scalene

Check another Triangle (y/n)? n
Press any key to continue . . .

Java, Programming

  • Category:- Java
  • Reference No.:- M92396167
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Java

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As