Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
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
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.
Account
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, Invoice.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
-discount:int
Discount rate in percent
+Customer(ID:int,name:String,
discount:int)
+getID():int
+getName ():String
+getDiscount():int
+setDiscount(discount:int):void
+toString():String
"name (ID)"
The Customer class models, a 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.
Invoice
- ID:int
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…
Chapter 9 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd 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 - Prob. 13MCCh. 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. 16PCCh. 9 - Lottery Statistics To play the PowerBall lottery,...Ch. 9 - Gas Prices In the student sample program files for...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Revise the loop shown in Listing 4.6 to use a break statement instead of the boolean variable areMore. Comment ...
Java: An Introduction to Problem Solving and Programming (7th Edition)
#inc1ude iostream using namespace std; int main() { cout ("hello")[1]; return 0; }
Starting Out with C++: Early Objects
The programs that translate high-level language programs into machine language are called.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
(Math: approximate the square root) There are several techniques for implementing the sqrt method in the Math c...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
What is the difference between the names defined in an ML let construct from the variables declared in a C bloc...
Concepts Of Programming Languages
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
- The ListInterface defines two constructors.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
- food_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_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_forward
- class Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Implement the function Singer Singer::combine(const Singer& rhs):It should create a new Singer object, by calling the constructor with the following values: For name it should pass a combination of be the name of the calling object followed by a '+' and then…arrow_forwardclass Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Task: Implement the function int Singer::changeme(std::string name,int age,int hits) : This function should check if the values passed by name, age and hits are different than those stored. And if this is the case it should change the values. This should be done by…arrow_forwardcode related to previously asked !!arrow_forward
- write also in c# Write an application that displays the result of dividing two numbers and displays anyremainder. The main() method prompts the user for values and sends them to the dividingmethod; the dividing method performs the calculation and displays the results. Save theapplication as Divide.csarrow_forwardA struct to store a single playing card is as follows: struct card { char suit; char kind; }; The valid suits are 'S', 'H', 'D' and 'C', while the valid kinds are 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', and 'K'. A poker hand can be stored as an array of five struct cards. A flush is a hand that contains five cards, all of the same suit. Write a function that returns 1, if the poker hand passed to it has five cards of the same suit, and 0 otherwise. int isFlush(struct card hand[]); int isFlush(struct card hand[]) {arrow_forwardclass Book: book_belongs_to = 'Schulich School of Engineering' def _init_(self, pages = 0, title = 'Unknown', author = 'Unknown', isbn = self.pages = pages self.title = title e): self.author = author self.isbn = isbn book1 = Book(255, 'Black Beauty', 'Anna Sewell', 9780001840423) book2 = Book(208, 'The Chrysalids', 'John Wyndham', 9780140013085) Book.book_belongs_to = 'Emily Marasco' book3 = Book()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