Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
Author: Joyce Farrell
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 5PE
Program Plan Intro
a.
Display the school name, sport name and team name
Program plan:
Filename: “Team.java”
- Define the “Team” class.
- Declare the required variables.
- Define the parameterized constructor.
- Set the values.
- Define “getSchoolName” method
- Return the school name.
- Define “getSportName” method
- Return the sport name.
- Define “getTeamName” method
- Return the team name.
Filename: “TestTeam.java”
- Define the “TestTeam” class.
- Define the main method.
- Create the objects for “Team” class with different parameters.
- Display the results.
- Define the main method.
Program Plan Intro
b.
Display the game details
Program plan:
Filename: “Team.java”
- Define the “Team” class.
- Declare the required variables.
- Define the parameterized constructor.
- Set the values.
- Define “getSchoolName” method
- Return the school name.
- Define “getSportName” method
- Return the sport name.
- Define “getTeamName” method
- Return the team name.
Filename: “Game.java”
- Define the “Game” class.
- Declare the required variables.
- Define the parameterized constructor.
- Set the values.
Filename: “TestTeam.java”
- Define the “TestTeam” class.
- Define the main method.
- Create the objects for “Team” class with different parameters.
- Create an object for “Game” class.
- Display the results.
- Define the main method.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
a - Create a FitnessTracker class that includes data fields for a fitness activity, the number of minutes spent participating, and the date. The class includes methods to get each field. In addition, create a default constructor that automatically sets the activity to running, the minutes to 0, and the date to January 1 of the current year. Save the file as FitnessTracker.java. Create an application that demonstrates each method works correctly, and save it as TestFitnessTracker.java.
b - Create an additional overloaded constructor for the FitnessTracker class you created in Exercise 3a. This constructor receives parameters for each of the data fields and assigns them appropriately. Add any needed statements to the TestFitnessTracker application to ensure that the overloaded constructor works correctly, save it, and then test it.
c - Modify the FitnessTracker class so that the default constructor calls the three-parameter constructor. Save the class as FitnessTracker2.java. Create an…
Create a class for Subject containing the Name of the subject and score of the subject. There should be following methods:
1. set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero.
2. set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero.
3. display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9”
4. getScore: it will return the value of score.
5. greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score.
Create a class “Main” having main method to perform following tasks.
1. Create two objects of Subject…
Help me With this Java Task
Chapter 4 Solutions
Java Programming (MindTap Course List)
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - Prob. 6RQCh. 4 - Prob. 7RQCh. 4 - Prob. 8RQCh. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - Prob. 17RQCh. 4 - Prob. 18RQCh. 4 - Prob. 19RQCh. 4 - Prob. 20RQCh. 4 - Prob. 1PECh. 4 - Prob. 2PECh. 4 - Prob. 3PECh. 4 - Prob. 4PECh. 4 - Prob. 5PECh. 4 - Prob. 6PECh. 4 - Prob. 7PECh. 4 - Prob. 8PECh. 4 - Prob. 9PECh. 4 - Prob. 10PECh. 4 - Prob. 11PECh. 4 - Prob. 1GZCh. 4 - Prob. 2GZ
Knowledge Booster
Similar questions
- Create a class for Subject containing the Name of the subject and score of the subject. There should be following methods: set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9” getScore: it will return the value of score. greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score. Create a class “Main” having main method to perform following tasks. Create two objects of Subject class having value “Math, 99.9”…arrow_forwardCreate a class for Subject containing the Name of the subject and score of the subject. There should be following methods: set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9” getScore: it will return the value of score. greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score. note....... solve with javaarrow_forwardFor your homework assignment, build a simple application for use by a local retail store. Your program should have the following classes: Item: Represents an item a customer might buy at the store. It should have two attributes: a String for the item description and a float for the price. This class should also override the __str__ method in a nicely formatted way. Customer: Represents a customer at the store. It should have three attributes: a String for the customer's name, a Boolean for the customer's preferred status, and a list of 5 indexes to hold Item objects. Include the following methods: make_purchase: accepts a String and a double as parameters to represent the name and price of an item this customer is purchasing. Create a new Item object with this info and append it to the internal list. If the customer is a preferred customer based on the Boolean attribute's value, take 10% off the total sale price. __str__: Override this method to print the customer's name and every…arrow_forward
- Task 8 Write a Cylinder class to get the desired output as shown below. 1. You will have to create a Cylinder class. 2. You will have to create 2 class variables. 3. Create a required constructor. 4. Write 2 class methods: • One that takes the height first and then the radius and then swaps One that takes a string where the radius and height values are separated with a hyphen. Write 2 static methods: One that calculates the area of a whole cylinder (formula: 2r? + 2rrh) • Another that calculates the volume of a cylinder (formula: Trh) **Observe the output values carefully to understand how the radius and height values are changing. [You are not allowed to change the code below] # Write your code here Output: Default radius=5 and height=18. Updated: radius=0 and height=0. c1 = Cylinder(0,0) Cylinder.area(c1.radius,c1.height) Cylinder.volume(c1.radius,c1.height) print("== c2 = Cylinder.swap(8,3) c2.area(c2.radius,c2.height) c2.volume(c2.radius,c2.height) print("==== c3 =…arrow_forwardDesign a class named CustomerRecord that holds a customer number, name, and address. Include separate methods to 'set' the value for each data field using the parameter being passed. Include separate methods to 'get' the value for each data field, i.e. "return" the field's value. Pseudocode:arrow_forwardA company accepts user orders by part numbers interactively. Users might make the following errors as they enter data: - The part number is not numeric. The quantity is not numeric. - The part number is too low (less than 0). - The part number is too high (more than 999). - The quantity ordered is too low (less than 1). - The quantity ordered is too high (more than 5,000). Create a class that stores an array of usable error messages; save the file as DataMessages.java. Create a DataException class; each object of this class will store one of the messages. Save the file as DataException.java. Create an application that prompts the user for a part number and quantity. Allow for the possibility of nonnumeric entries as well as out-of-range entries, and display the appropriate message when an error occurs. If no error occurs, display the message "Valid entry". Save the program as PartAndQuantityEntry.java.arrow_forward
- Create a class named Ship that has two private fields one for the name (string)of the ship, and the other for the year (string) the ship was built. The classcontains a parameterized constructor to set the values of each field get methods for each of the fields display method to display ship’s information.Create a class named CruiseShip that extends Ship class. CruiseShip class should have a private field for the maximum number of passengers (int).The class contains- a parameterized constructor to set the value of the field- get and set method for the field- a display method that overrides ship class display method anddisplay CruiseShip information.Create an application/class named CruiseShipDemo that allows a user toenter values to create 5 CruiseShip objects and save them in the array. Display the records.The CruiseShipDemo class should have a method named update to updatethe CruiseShips information. The method prompts the user for the ship name, if the requested record does not…arrow_forwardPlease help me with this Java Labarrow_forwardCreate the StockTask1 Java project Create a Stock object class that contains the following information: The symbol of the stock is stored in a private string data field called symbol. The stock's name is stored in a private string data field called name. previousClosingPrice is a private double data area that stores the stock price for the previous day. currentPrice is a private double data area that stores the stock price at the current time. A constructor for creating a stock with the given symbol and name. For the data fields, there are accessor methods (get-methods). For the data fields, there is a mutator method (set-methods). A method named getChangePercent()that returns the percentage changed from previousClosingPrice to currentPrice. Formula:perc_change = (current price - previous closing price) / previous closing price x 100 Create a test class named testStockthat creates a Stockobject with the stock symbol SUNW, the name Sun Microsystems Inc., and the previous closing…arrow_forward
- Static & Not Final Field: Accessed by every object, Changing Non-Static & Final Field: Accessed by object itself, Non-Changing Static & Final: Accessed by every object, Non-Changing Non-Static & Not Final Field: Accessed by object itself, ChangingRead the following situation and decide how the variables should be defined. You have a class named HeartsPlayerA round of Hearts starts with every player having 13 cardsPlayers then choose 3 cards to “trade” with a player (1st you pass left, 2nd you pass right, 3rd you pass across, 4th you keep)Players then strategically play cards in order to have the lowest scoreAt the end of the round, points are cumulatively totaled for each player.If one player’s total is greater than 100, the game ends and the player with the lowest score wins. 1. How should the following data fields be defined (with respect to final and static)?(a) playerPosition (These have values of North, South, East, or West)(b) directionOfPassing(c) totalScore…arrow_forwardmau Open Leathing inta... - The class has data members that can hold the name of your cube, length of one of the sides and the color of your cube. - The class has a constructor that accepts the name, length of one of the sides, and color as arguments and sets the data members to those values. - The class has the following methods to set the corresponding data member. setName(string newName) setSide(double newSide) setColor(string newColor) - The class has a method called getVolume() that returns the volume of the cube, calculated by cubing the length of the side. - The class has a method called volumelncrease(double newVolume) that receive the percent the volume should increase, and then the side to the corresponding value. i - For example, 2.5 indicates 2.5% increasing of the volume. So you take the current volume, increase it by 2.5%, and then find the cube root to calculate the new side length. You can use the built in function called cbrt, part of the math library, to find the cube…arrow_forwardInstructions: IMPORTANT: This is a continuation of the previous part of the project and assumes that you are starting with code that fulfills all requirements from that part of the project. Modify the your code from the previous part of the project to make it modular. In addition to the main method, your code must include the following static methods: Method 1 - displayTitle A method that creates a String object in memory to hold the text “Computer Hardware Graphics Quality Recommendation Tool” and displays it Method 2 – getResolutionString A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution. The method should return the appropriate String representation of the monitor resolution. For example, if the method is passed an integer value of 1, it should return a String with a value of “1280 x 720”. (See Step 4 of Project 1) Method 3 – getMultiplierValue A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution and…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,