Starting Out with Java: From Control Structures through Objects (6th Edition)
6th Edition
ISBN: 9780133957051
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 9.3, Problem 9.9CP
Look at the following declaration:
String cafeName = “Broadway Cafe”;
String str;
Which of the following methods would you use to make str reference the string “Broadway”?
startsWith
regionMatches
substring
indexOf
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The __str__ method of the Bank class (in bank.py) returns a string containing the accounts in random order. Design and implement a change that causes the accounts to be placed in the string in ascending order of name.
Implement the __str__ method of the bank class so that it sorts the account values before printing them to the console.
In order to sort the account values you will need to define the __eq__ and __lt__ methods in the SavingsAccount class (in savingsaccount.py).
The __eq__ method should return True if the account names are equal during a comparison, False otherwise.
The __lt__ method should return True if the name of one account is less than the name of another, False otherwise.
The program should output in the following format:
Test for createBank: Name: Jack PIN: 1001 Balance: 653.0 Name: Mark PIN: 1000 Balance: 377.0 ... ... ... Name: Name7 PIN: 1006 Balance: 100.0
bank.py
"""
File: bank.py
Project 9.3
The str for Bank returns a string of accounts sorted by name.…
Appointment Class Requirements
The appointment object shall have a required unique appointment ID string that cannot be longer than 10 characters. The appointment ID shall not be null and shall not be updatable.
The appointment object shall have a required appointment Date field. The appointment Date field cannot be in the past. The appointment Date field shall not be null.Note: Use java.util.Date for the appointmentDate field and use before(new Date()) to check if the date is in the past.
The appointment object shall have a required description String field that cannot be longer than 50 characters. The description field shall not be null.
Appointment Service Requirements
The appointment service shall be able to add appointments with a unique appointment ID.
The appointment service shall be able to delete appointments per appointment ID.
A mountain climbing club maintains a record of the climbs that its members have made. Information about a climb includes the name of the mountain peak and the amount of time it took to reach the top. The information is contained in the ClimbInfo class as declared below.
The ClimbingClub class maintains a list of the climbs made by members of the club. The declaration of the ClimbingClub class is shown below. You will write implementations of the addClimb method.
import java.util.List;
import java.util.ArrayList;
class ClimbInfo
{
private String name;
private int time;
/** Creates a ClimbInfo object with name peakName and time climbTime.
*
* @param peakName the name of the mountain peak
* @param climbTime the number of minutes taken to complete the climb */
public ClimbInfo(String peakName, int climbTime)
{
name = peakName;
time = climbTime;
}
/** @return the name of the mountain peak */
public String getName()
{
return name;
}
/** @return the number of minutes…
Chapter 9 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Write an if statement that displays the word digit...Ch. 9.2 - Prob. 9.3CPCh. 9.2 - Write a loop that asks the user, Do you want to...Ch. 9.2 - Prob. 9.5CPCh. 9.2 - Write a loop that counts the number of uppercase...Ch. 9.3 - Prob. 9.7CPCh. 9.3 - Modify the method you wrote for Checkpoint 9.7 so...Ch. 9.3 - Look at the following declaration: String cafeName...Ch. 9.3 - Prob. 9.10CP
Ch. 9.3 - Prob. 9.11CPCh. 9.3 - Prob. 9.12CPCh. 9.3 - Prob. 9.13CPCh. 9.3 - Look at the following code: String str1 = To be,...Ch. 9.3 - Prob. 9.15CPCh. 9.3 - Assume that a program has the following...Ch. 9.4 - Prob. 9.17CPCh. 9.4 - Prob. 9.18CPCh. 9.4 - Prob. 9.19CPCh. 9.4 - Prob. 9.20CPCh. 9.4 - Prob. 9.21CPCh. 9.4 - Prob. 9.22CPCh. 9.4 - Prob. 9.23CPCh. 9.4 - Prob. 9.24CPCh. 9.5 - Prob. 9.25CPCh. 9.5 - Prob. 9.26CPCh. 9.5 - Look at the following string:...Ch. 9.5 - Prob. 9.28CPCh. 9.6 - Write a statement that converts the following...Ch. 9.6 - Prob. 9.30CPCh. 9.6 - Prob. 9.31CPCh. 9 - The isDigit, isLetter, and isLetterOrDigit methods...Ch. 9 - Prob. 2MCCh. 9 - The startsWith, endsWith, and regionMatches...Ch. 9 - The indexOf and lastIndexOf methods are members of...Ch. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - To delete a specific character in a StringBuilder...Ch. 9 - Prob. 12MCCh. 9 - This String method breaks a string into tokens. a....Ch. 9 - These static final variables are members of the...Ch. 9 - Prob. 15TFCh. 9 - Prob. 16TFCh. 9 - True or False: If toLowerCase methods argument is...Ch. 9 - True or False: The startsWith and endsWith methods...Ch. 9 - True or False: There are two versions of the...Ch. 9 - Prob. 20TFCh. 9 - Prob. 21TFCh. 9 - Prob. 22TFCh. 9 - Prob. 23TFCh. 9 - int number = 99; String str; // Convert number to...Ch. 9 - Prob. 2FTECh. 9 - Prob. 3FTECh. 9 - Prob. 4FTECh. 9 - The following if statement determines whether...Ch. 9 - Write a loop that counts the number of space...Ch. 9 - Prob. 3AWCh. 9 - Prob. 4AWCh. 9 - Prob. 5AWCh. 9 - Modify the method you wrote for Algorithm...Ch. 9 - Prob. 7AWCh. 9 - Look at the following string:...Ch. 9 - Assume that d is a double variable. Write an if...Ch. 9 - Write code that displays the contents of the int...Ch. 9 - Prob. 1SACh. 9 - Prob. 2SACh. 9 - Prob. 3SACh. 9 - How can you determine the minimum and maximum...Ch. 9 - Prob. 1PCCh. 9 - Prob. 2PCCh. 9 - Prob. 3PCCh. 9 - Prob. 4PCCh. 9 - Prob. 5PCCh. 9 - Prob. 6PCCh. 9 - Check Writer Write a program that displays a...Ch. 9 - Prob. 8PCCh. 9 - Prob. 9PCCh. 9 - Word Counter Write a program that asks the user...Ch. 9 - Sales Analysis The file SalesData.txt, in this...Ch. 9 - Prob. 12PCCh. 9 - Alphabetic Telephone Number Translator Many...Ch. 9 - Word Separator Write a program that accepts as...Ch. 9 - Pig Latin Write a program that reads a sentence as...Ch. 9 - Prob. 16PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Give the declaration for two variables called count and distance, count is of type int and is initialized to ze...
Absolute Java (6th Edition)
What are the advantages and disadvantages of implicit declarations?
Concepts of Programming Languages (11th Edition)
Where do you declare class-level variables?
Starting Out With Visual Basic (7th Edition)
A file that contains a Flash animation uses the __________ file extension. a. .class b. .swf c. .mp3 d. .flash
Web Development and Design Foundations with HTML5 (8th Edition)
Define each of the following terms: determinant functional dependency transitive dependency recursive foreign k...
Modern Database Management
What does the following code print? System.out.println(""); System.out.println(""); System.out.println(""); Sys...
Java How To Program (Early Objects)
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
- Implement all the classes using Java programming language from the given UML Class diagram. Note: This problem requires you to submit just two classes: Customer.java, Account.java. Do NOT include "public static void main()" method inside all of these classes. Graders will be testing your classes, using the unit-testing framework JUnit 4. Customer - ID:int -name:String -gender:char 'm' or 'f' +Customer(ID:int,name:String, discount:int) +getID():int +getName ():String +getGender ():char +toString():String "name (ID)" The Customer class models, customer design as shown in the class diagram. Write the codes for the Customer class and a test driver to test all the public methods. Accountarrow_forwardprivate OnlineStudent readOnlineStudent(Scanner pIn) { String id = pIn.next(); String lname = pIn.next(); String fname = pIn.next(); OnlineStudent student = new OnlineStudent(id, fname, lname); String fee = pIn.next(); int credits = pIn.nextInt(); if (fee.equals("T")) { student.setTechFee(true); else { student.setTechFee(false); } student.setCredits(credits); return student; keep getting class, interface,enum or record expected. I need helparrow_forwardA class object can encapsulate more than one [answer].arrow_forward
- The xxx_Student class:– Name - the name consists of the First and Last name separated by a space.– Student Id – a whole number automatically assigned in the student class– Student id numbers start at 100. The numbers are assigned using a static variable in the Student class• Include all instance variables• Getters and setters for instance variables• A static variable used to assign the student id starting at 100• A toString method which returns a String containing the student name and id in the format below:Student: John Jones ID: 101 The xxx_Course classA Course has the following information (modify your Course class):– A name– An Array of Students which contains an entry for each Student enrolled in the course (allow for up to 10 students)– An integer variable which indicates the number of students currently enrolled in the course. Write the constructor below which does the following:Course (String name)Sets courseName to nameCreates the students array of size 10Sets number of…arrow_forward3. Complete the implementations of the conversion methods: a. double toDouble () const; This method returns the corresponding value the string in double type. For example, if we have an object str: CustomString str("99.50"); then this operation: double number will give the number = 99.50. = str.toDouble();arrow_forwardclass Book: book_belongs_to = 'Schulich School of Engineering' def _init_(self, pages = e, title = 'Unknown', author = 'Unknown', isbn self.pages = pages e): %3D self.title = title self.author = author self.isbn = isbn Book (255, 'Black Beauty', 'Anna Sewell', 9780001840423) Book (208, 'The Chrysalids', 'John Wyndham', 9780140013085) book1 = book2 = Book.book_belongs_to 'Emily Marasco' %3D book3 = Book ()arrow_forward
- Part 2. fill Method Define a method in simpy named fill. Its purpose is to fill a simpy's values with a specific number of repeating values. The fill method will have two parameters following self: 1. The float value you are filling the values list in with. 2. The int number of values to fill in. The fill method is procedure-like in that it returns None and mutates the object the method is called on. After calling fill, the length of the Simpy object's values should be equal to the second argument given to fill. For example, consider the following usage and expected printed output, given inline, below: twos = Simpy([]) twos.fill(2.0, 3) print("Actual: ", twos, Expected: Simpy([2.0, 2.0, 2.0])") twos.fill(2.0, 5) print("Actual: ", twos, " - Expected: Simpy([2.0, 2.0, 2.0, 2.0, 2.0])") mixed = Simpy([]) mixed.fill(3.0, 3) - Expected: Simpy([3.0, 3.0, 3.0])") print("Actual: ", mixed, mixed.fill(2.0, 2) print("Actual: ", mixed, Expected: Simpy ([2.0, 2.0])") Pythonarrow_forwardfood_wastage_record.hpp class FoodWastageRecord {public:void SetDate(const std::string &date);void SetMeal(const std::string &meal);void SetFoodName(const std::string &food_name);void SetQuantityInOz(double qty_in_oz);void SetWastageReason(const std::string &wastage_reason);void SetDisposalMechanism(const std::string &disposal_mechanism);void SetCost(double cost); std::string Date() const;std::string Meal() const;std::string FoodName() const;double QuantityInOz() const;std::string WastageReason() const;std::string DisposalMechanism() const;double Cost() const; private:std::string date_;std::string meal_;std::string food_name_;double qty_in_oz_;std::string wastage_reason_;std::string disposal_mechanism_;double cost_;}; food_wastage_record.cpp #include "food_wastage_record.h" void FoodWastageRecord::SetDate(const std::string &date) { date_ = date; }void FoodWastageRecord::SetMeal(const std::string &meal) { meal_ = meal; }void…arrow_forwardOverview: A new bank wants to make a simple application to keep track of all accounts and transactions. In this TMA, it is required to help the bank manager implement the required application. Requirements: After a quick meeting with the bank manager, you got the following information: It is required to store all bank accounts in one collection and all the transactions happened in another collection. Each account has a unique account number, a holder and balance. There is a specific prefix (common for all accounts) that should be added to the holder's civil id to create the unique account number. In addition, it is not allowed for a holder to have more than one account. Furthermore, only three transactions are allowed on any account: deposit, withdrawal and transfer money to another account. Each holder has a unique civil ID (national id), a name and other attributes (add at least 2 attributes from your choice). For each transaction, it is required to store the account(s) affected,…arrow_forward
- function removeErrMsgs() { var errMessages = document.getElementsByClassName('msg');for (let msg of errMessages) {msg.innerHTML = "";}}function validateValues() {var toBeReturned = true;removeErrMsgs();var fname = document.getElementById("fname").value;if (fname.length > 30) {document.getElementsByClassName('msg')[0].innerHTML = "First name can not be longer than 30 characters";toBeReturned = false;} var lname = document.getElementById("lname").value;if (lname.length > 30) {document.getElementsByClassName('msg')[1].innerHTML = "Last name can not be longer than 30 characters";toBeReturned = false;} var phone = document.getElementById('num').value;if (phone.length > 8) {document.getElementsByClassName('msg')[2].innerHTML = "Phone number can not be greater than 8 numbers";toBeReturned = false;} var items = document.getElementById('items').value;if (items > 4 || items < 2) {document.getElementsByClassName('msg')[3].innerHTML = "Item numbers should be between 1 and…arrow_forwardclass Student: def _init_(self, firstname, lastname, idnum): self.first = firstname self.last = lastname self.id = idnum self.courses = [] def add_course(self, course): ''' don't allow overloads or signing up for the same course twice if course not in self.courses and len(self.courses) = 4 What are all of the attributes of this class? last overload idnum add_course self first course firstname courses id clear_courses lastnamearrow_forwardamples: dayOfWeek (1) -> "Sunday" dayOfWeek (4) -> "Wednesday" Your Answer: 1 public String dayOfWeek (int dayNum) 2 { 3 4}arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY