EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
Chapter 1, Problem 9PE
Program Plan Intro
Triangle
Define the class “Triangle”.
- Define the main method.
- Display triangle in the output window using the pattern in print statements.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Please follow the steps to complete JAVA PROGRAM
Create a class, EmployeeException, that has the following attributes:
name: String
SSN: String
Salary: double
The methods required in this class are:
A constructor with no arguments that sets the attributes at default values
A constructor that passes values for all attributes
Accessor, mutator, display method for each attribute. An example of a display method for an attribute is writeOutName(): void, in which you just display the name:System.out.println("Employee Name: " + name);
An equals method that has an object of type Employee as argument, and returns true if two employees have the same name, salary, and SSN.
Write a driver program for the Employee class that uses an array that can hold up to 100 employees (the array will be of EmployeeException type). However, the user should be free to enter as many employees as needed.
The driver class should use two exception classes to signal the user that the SSN entered is not correct.…
JAVA PROGRAMMING - Write a program that displays the employees Ids together with their first and last names. Use two classes. The first class contains the employee data and separate methods to set and get the ID’s and names. The other class creates objects for the employees and uses the objects to call the methods. Create several employees and display their data.
must attach output screenshot
Chapter 1 Solutions
EBK JAVA PROGRAMMING
Ch. 1 - Prob. 1RQCh. 1 - Prob. 2RQCh. 1 - Prob. 3RQCh. 1 - Prob. 4RQCh. 1 - Prob. 5RQCh. 1 - Prob. 6RQCh. 1 - Prob. 7RQCh. 1 - Prob. 8RQCh. 1 - Prob. 9RQCh. 1 - Prob. 10RQ
Ch. 1 - Prob. 11RQCh. 1 - Prob. 12RQCh. 1 - Prob. 13RQCh. 1 - Prob. 14RQCh. 1 - Prob. 15RQCh. 1 - Prob. 16RQCh. 1 - Prob. 17RQCh. 1 - Prob. 18RQCh. 1 - Prob. 19RQCh. 1 - Prob. 20RQCh. 1 - Prob. 1PECh. 1 - Prob. 2PECh. 1 - Prob. 3PECh. 1 - Prob. 4PECh. 1 - Prob. 5PECh. 1 - Prob. 6PECh. 1 - Prob. 7PECh. 1 - Prob. 8PECh. 1 - Prob. 9PECh. 1 - Prob. 10PECh. 1 - Prob. 11PECh. 1 - Prob. 12PECh. 1 - Prob. 1DECh. 1 - Prob. 1GZCh. 1 - Prob. 1CPCh. 1 - Prob. 2CP
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Program.java Part 1: requires three files: Design and save your Motor class before you make Vehicle, so you can specify Motor as a Vehicle data attribute. Class Motor (make this class first because Motor is an attribute of class Vehicle)Attributes (all private) int cylinders int hp String type (possible values being gas, deisel, electric etc) Methods (all public) a constructor that can assign values to all attributes getters and for each attribute (setters not needed) a toString method that returns the status of a Motor instance, all attributes. Class VehicleAttributes (all private) String make String model int year double price Motor motor (see below) Methods (public) a constructor that can assign values to all attributes a setter for the price a getter for the price a toString method that returns the status of a Vehicle instance, all attributes. Class TestVehicleThis is the executable class. In the main method, make an arraylist of five or six Vehicle instances and then use a…arrow_forwardUsing oop in java Create a class “Main” having main method to perform following tasks. Create two objects of Subject class having value “Math, 99.9” and “Physics, 98.9” respectively. Display the values of both objects Change the value of object from 99.9 to 89.9 Compare both objects and display the values of the subject which have lowest score.arrow_forwardPart 2 in java pleasearrow_forward
- Please do it in JavaScript or C# 1) Design and implement the class structure for a drawing application. A drawing is made up of a canvas that contains a collection of three different shapes: circles, lines, and boxes. Each shape can be drawn by calling a Draw() method for that shape. The canvas class should also have a draw method that draws all of the shapes it contains. You don’t have to actually draw anything on a screen; you can simulate drawing by writing a message to the console.For example, the code snippet: canvas.Draw();Drawing a circle at...Drawing a line at...etc. (For each shape on the canvas) 2)(Bonus) Consider re-writing the above answer (#1) differently where the canvas does not contain the shapes, but is able to draw any of the three shapes passed to it. Re-design canvas.Draw() if you need to. Your main() program should ask for user input on what shape to draw. Ask once, draw, then exit.could produce something like the following output to the console:arrow_forwardPython Program: Write a program which controls a metro train and that keeps track of stations and who gets on and off. Design and implement a class called train, which has at least the following: At least the following attributes (you can include others): metroID stationNum which keeps track of the station that the train is at. iii. direction which keeps track of the direction the train is travelling in. passTotal which keeps track of the number of passengers currently on the train. A default constructor which sets the metroID to a random number between 1 and 1000, the station number to 0, the direction (int), and the passTotal to 0 (train is empty). A constructor with one parameter; the parameter is the metro id. The constructor assigns the passed integer to the metroID attribute; the rest of the attributes are set as described in the default constructor. Accessor methods for each attributes. Mutator methods for each attributes. nextStation(int lastStation) which determines…arrow_forwardPlease do this in Java! Thank you 10. Ship, CruiseShip, and CargoShip Classes Design a Ship class that the following members: • A field for the name of the ship (a string). • A field for the year that the ship was built (a string). • A constructor and appropriate accessors and mutators. • A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: • A field for the maximum number of passengers (an int). • A constructor and appropriate accessors and mutators. • A toString method that overrides the toString method in the base class. The CruiseShip class’s toString method should display only the ship’s name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: • A field for the cargo capacity in tonnage (an int). • A constructor and appropriate accessors and mutators. • A…arrow_forward
- ompiling and Executing a Java Program Summary In this lab, you compile and execute a prewritten Java program. Instructions Execute the program. There should be no syntax errors. Modify the program so it displays "I'm learning how to program in Java.". Execute the program. Modify the Programming class so it prints two lines of output. Change the class name to Awesome. In Java, the file name must match the class name, so change the file name to Awesome.java. Add a second output statement that displays "That's awesome!". Execute the program.arrow_forwardDesign a class named Author with the following members: A field for the author’s name (a String) A field for the author’s year of birth (an int) One or more constructors and appropriate accessor and mutator methods A toString method that displays the author’s info as: Author: Mary Shelley (1797) Save the file as Author.java. Next, create an abstract class named Book with the following members: A field for the book title (a String) A field for the book author (a reference to an Author object) A field for the book price (a double) A constructor that requires the title and author Get methods for the title, author, and price An abstract method named setPrice A toString method that displays the book’s title, author’s info, and price as: Frankenstein Author: Mary Shelley (1797) Price: $23.95 Save the file as Book.java. Create Fiction and NonFiction child classes of Book. Each must include a setPrice method that sets the price for all Fiction books to $23.95 and for all NonFiction books…arrow_forwardin javaarrow_forward
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is correct. Each question has one correct answer. Thank you. Part 1 - 1. Which is the correct way for a subclass to inherit a superclass in Java? A. class subclass : superclassB. class subclass extends superclassC. class superclass : subclassD. class subclass imports superclassE. class subclass implements superclass Part 2 - 2. Given the following code, the output is __. class Base { public int x = 5; }class Derived extends Base { public int x = 6; }public class Sample { public static void main(String[] args) { int x = 7; Derived d1 = new Derived(); System.out.print(d1.x); }} A. 0B. 5C. 6D. 7E. Error messagearrow_forwardin javaarrow_forwardInternally your program should have two Java classes: ValidatorNumeric (superclass) ValidatorString (subclass) The subclass ValidatorString extends ValidatorNumeric class, forming a hierarchy of two classes. Add a separate main class with the main() method to test all public methods in both ValidatorNumeric and ValidatorString classes. The main() method should create the necessary objects and run the user interaction as shown above. The ValidatorNumeric class is responsible for capturing user prompt and a range of valid numeric inputs. Its methods display the prompt and accept input from the user. It should provide the following public interface: // Default constructor ValidatorNumeric() // Specific constructor taking params as follows: ValidatorNumeric( String prompt, int min, int max ) // Another specific constructor taking params as follows: ValidatorNumeric( String prompt, double min, double max ) // Method that shows user prompt and gets an int from the user: public…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY