Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 1.2, Problem 17STQ
Program Plan Intro
Byte code:
Java
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
in java :
Implement the following class:
Class name: Student
- where an instance of class Student represents a student.
Private member variables:
· name, which is a String representing the name of the student
· class, which is a String representing the class the student is enrolled in (i.e. CS155)
· grade, which is a String representing the grade of the student (i.e. A, B, C, D, F) (they are all-capital-letters)
Public member methods:
- a constructor ()
- set name
- set class
- set grade
- get name
- get class
-get grade
Write a test program (main method) that:
· Maintains an array studentArray of base type Student
Student [] studentArray;
· The program will read from the user and store the information of the following 7 (SEVEN) students:
Dalia Thomas
CS155
A
Sarah Johns
CS155
A
Adam Jack
CS155
B
Sandra Johnson
CS256
A
Tim Locks
CS155
C
Laila Zelle
CS265
C
Sam Adams
CS265
A…
Python:Please read the following.
The Game class
The Game class brings together an instance of the GameBoard class, a list of Player objects who are playing the game, and an integer variable “n” indicating how many tokens must be aligned to win (as in the name “Connect N”).
The game class has a constructor and two additional methods. The most complicated of these, play, is provided for you and should not be modified. However, you must implement the constructor and the add_player method.
__init__(self,n,height,width)
The Game constructor needs to initialize three instance variables. The first, self.n, simply holds the integer value “n” provided as a parameter. The second, self.board, should be a new instance of the GameBoard class (described below), built using the provided height and width as dimensions. The third, self.players, should be an initially empty list.
add_player(self,name,symbol)
The add_player method is provided a name string and a symbol string. These two values should be…
write code in python language
Chapter 1 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 1.1 - What are the two kinds of memory in a computer?Ch. 1.1 - What is software?Ch. 1.1 - What data would you give to a program that...Ch. 1.1 - What data would you give to a program that...Ch. 1.1 - What is the difference between a program written...Ch. 1.1 - Is Java a high-level language or a low-level...Ch. 1.1 - Is Java bytecode a high-level language or a...Ch. 1.1 - What is a compiler?Ch. 1.1 - What is a source program?Ch. 1.1 - What do you call a program that translates Java...
Ch. 1.2 - What would the following statement, when used in a...Ch. 1.2 - Write a statement or statements that can be used...Ch. 1.2 - Prob. 13STQCh. 1.2 - What is the meaning of the following line in the...Ch. 1.2 - Write a complete Java program that uses system....Ch. 1.2 - Suppose you define a class named YourClass in a...Ch. 1.2 - Prob. 17STQCh. 1.3 - What is a method?Ch. 1.3 - Prob. 19STQCh. 1.3 - Do all objects of the same class have the same...Ch. 1.3 - Prob. 21STQCh. 1.3 - Prob. 22STQCh. 1.3 - Prob. 23STQCh. 1.3 - Prob. 24STQCh. 1.3 - What is an algorithm?Ch. 1.3 - What is pseudocode?Ch. 1.3 - Prob. 27STQCh. 1.3 - Prob. 28STQCh. 1.3 - Prob. 29STQCh. 1.3 - Prob. 30STQCh. 1.3 - Prob. 31STQCh. 1.3 - Suppose you write a program that is supposed to...Ch. 1.4 - Prob. 33STQCh. 1.4 - Prob. 34STQCh. 1 - How does a computers main memory differ from its...Ch. 1 - Prob. 2ECh. 1 - Prob. 3ECh. 1 - How does machine language differ from Java?Ch. 1 - What would the following statements, when used in...Ch. 1 - Write a statement or statements that can be used...Ch. 1 - Write statements that can be used in a Java...Ch. 1 - Given a persons year of birth, the Birthday Wizard...Ch. 1 - Write statements that can be used in a Java...Ch. 1 - Prob. 11ECh. 1 - Prob. 12ECh. 1 - Prob. 13ECh. 1 - Prob. 14ECh. 1 - What attributes and behaviors would an object...Ch. 1 - Suppose that you have a numberxthat is greater...Ch. 1 - Prob. 17ECh. 1 - Prob. 18ECh. 1 - Prob. 19ECh. 1 - Prob. 20ECh. 1 - Obtain a copy of the Java program shown in Listing...Ch. 1 - Modify the Java program described in Practice...Ch. 1 - Prob. 3PCh. 1 - The following program will compile but it has...Ch. 1 - Programming Projects require more problem-solving...Ch. 1 - Write a complete program for the problem described...Ch. 1 - Prob. 3PPCh. 1 - Prob. 4PPCh. 1 - Write an applet program for the problem described...Ch. 1 - Prob. 6PP
Knowledge Booster
Similar questions
- In Java, we may create arbitrary arrays of class objects. In or out?arrow_forwardFirst, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A. A first name (given name)B. A last name (family name/surname)C. Student number (ID) – an integer number (of type long)D. A date of birth (in day/month/year format – three integers) - (Create your own Date class, the Date class should be a separate class from this. Do NOT use the Date class from JAVA.)The Student class will have at least the following constructors and methods:(i) two constructors - one without any parameters (the default constructor), and one with parameters to give initial values to all the instance variables of Student. (ii) only necessary set and get methods for a valid class design. (iii) a reportGrade method, which you have nothing to report here, you can just print to the screen a message “There is no grade here.”. This method will be overridden in the respective child…arrow_forwardCan someone help me write a class in Java. The class will read a file of people: their name, year of birth, and year of death. The class must have at least one ArrayList. The class's constructor will read the file specified by its parameter. Each line looks like the samplebelow:FirstName LastName YearOfBirth YearOfDeathThe items on each line are separated by tabs. The class will also have these methods: -preBoom() : This method will return the number of people born before 1945, the start ofthe Baby Boom - minAge() : This method will return the age of the youngest person in the list - maxAge() : This method will return the age of the oldest person in the list - aveAge() : This method will return the average age of the people in the list. Theaverage value returned will be an integer. - seniors() : This method will return the number of people aged 65 or overarrow_forward
- Create a class Animal Create a class Cat, and a class Dog, and a class Bearded Dragon which extend Animal. Add to your Animal class: Member: name Methods: Public Animal (String name) //constructor public void makes Sound () with the implementation printing out a generic animal sound. Next, override (add) the makes Sound() method to your Cat and Dog class, with the implementation specific to each animal (i.e, cat says purr..). Do not override the makesSound() for your Dragon (bearded dragons don't make sounds!) Note, you'll also need a constructor in each of your subclasses which calls super(name) to initialize the common 'name' member of Animal. Next (in your test harness) create a List of different Animals ( a couple cats, a dog, a dragon... ) and add these Animals to your list. Iterate through your list & call makeSound on each. (you should observe the makeSound method called will be: cat -> from Cat class, dog-> from Dog class, bearded Dragon -> from Animal class ) EC:…arrow_forwardWrite the source code of the class CrewMember. A crew member cannot change its duty type. For example, a hostess can never become a pilot. The number of years to become a senior member should be obtained from the class FlightRules. How can we write FlightRules class its enough for me?arrow_forwardUOWD Library is asking you to write a Java program that manages all the items in the Library. The library has books, journals, and media (DVD for example). All items have a name, author(s), and year of publication. A journal also has a volume number, while a media has a type (audio/video/interactive). The user of your program should be able to add an item, delete an item, change information of an item, list all items in a specific category (book, journal, or media), and print all items (from all categories). A menu asks the user which operation s/he wants to perform. Important: make use of collections, inheritance, interfaces, and exception handling wherever appropriate.arrow_forward
- Write a program in Java that handles the order list for an online retailer. Your program should contain a minimum of three classes: Order Class Display Class Main Class Create a Order Class that uses a queue to hold the orders in the order they were taken. The queue should contain the customer last name, order number, and order total cost. Create a Display Class that will store a copy of the order queue in two arrays. Each array will contain the order list but one will be sorted by name and the other sorted by order number. When a order is taken and stored in the Order Class the program will update theDisplay Class arrays automatically sort them in descending order using quick sort and outputs the the contents to the console upon each entry of new data. Create a Main Class that will handle operator data input and when an order is added or removed, the program will update the Order Class and Display Class. The user will be presented a menu to add a order, remove a order and display…arrow_forwardJava Program The assignment requires two classes. Put all classes in the same package. Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int Methods: Parameterized constructor for initializing a new Employee instance Getters for all attributes toString method to display an Employee's attributes (See output of executable below) Executable Class Create an array of at least eight Employee objects. Be sure to use many with identical last names, but don't order them by name in the array. Create an ArrayList from the array. Sort the ArrayList first by last name and then by first name. Using the forEach method and a lambda expression, print all employees alphabetically sorted by name. Create a LinkedList from the ArrayList. Create an iterator capable of cycling both forward and backward through the LinkedList. Iterate forward through the LinkedList without generating any output. Then iterate backwards through the LinkedList to print…arrow_forwardWrite a java classarrow_forward
- First, you need to design, code in Java, test and document a base class, Student. The Student class willhave the following information, and all of these should be defined as Private:A. Title of the student (eg Mr, Miss, Ms, Mrs etc)B. A first name (given name)C. A last name (family name/surname)D. Student number (ID) – an integer number (of type long)E. A date of birth (in day/month/year format – three ints) - (Do NOT use the Date class fromJAVA)The student class will have at least the following constructors and methods:(i) two constructors - one without any parameters (the default constructor), and one withparameters to give initial values to all the instance variables.(ii) only necessary set and get methods for a valid class design.(iii) method to write the output of all the instance variables in the class to the screen (which willbe overridden in the respective child classes, as you have more instance variables thatrequired to be output).(iv) an equals method which compares two…arrow_forwardFirst, you need to design, code in Java, test and document a base class, Student. The Student class willhave the following information, and all of these should be defined as Private:A. Title of the student (eg Mr, Miss, Ms, Mrs etc)B. A first name (given name)C. A last name (family name/surname)D. Student number (ID) – an integer number (of type long)E. A date of birth (in day/month/year format – three ints) - (Do NOT use the Date class fromJAVA)The student class will have at least the following constructors and methods:(i) two constructors - one without any parameters (the default constructor), and one withparameters to give initial values to all the instance variables.(ii) only necessary set and get methods for a valid class design.(iii) method to write the output of all the instance variables in the class to the screen (which willbe overridden in the respective child classes, as you have more instance variables thatrequired to be output).(iv) an equals method which compares two…arrow_forwardIn this java assignment, we will be creating a paystub for an employee using classes, files, getters, and setters. Each file should only have one class and the class should share the same name as the file. We are going to implement the following classes: Employee - This class represent the employee. It needs the following fields exposed via getters and setters: Employee ID (hard code it to 1) First name, last name, middle initial Address, city, zip Phone, email Hourly rate PayPeriod - This class represents an employee's payment information. An employee will eventually have more than one pay period. It needs the following fields exposed via getters and setters: Pay period Id (hard code to 123456) Employee Id Start date, end date Number of hours PayrollManager - This class provides the functionality we need to compute and display the payroll. It should implement the following methods: double CalculateGrossPay (Employee, PayPeriod) - this should return the total gross for the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education