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, Problem 1AW
The following if statement determines whether choice is equal to ‘Y’ or ‘y’:
if (choice == ‘Y’ | | choice == ‘y’)
Rewrite this statement so it makes only one comparison and does not use the | | operator. (Hint: Use either the toUpperCase or toLowerCase method.)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assume choice references a string. The following if statement determines whether choice is equal to ‘Y’ or ‘y’:if choice == 'Y' or choice == 'y':Rewrite this statement so it only makes one comparison and does not use the or operator. (Hint: use either the upper or lower methods.)
The strict equal operator is
Select one:
a. !=
b.==
C.===
d.=
Name:
Claz
4. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
The code segment below is intended to display all multiples of 5 between the values start and end, inclusive.
For example, if start has the value 35 and end has the value 50, the code segment should display the values
35, 40, 45, and 50. Assume that start and end are multiples of 5 and that start is less than end.
Line 1: i + start
Line 2: REPEAT TIMES
Line 3: {
DISPLAY (i)oplev a bonin vimobn ldemyA
i + i + 5
Line 4:
Line 5:
Line 6: }
Which of the following could replace in line 2 so that the code segment works
as intended?
wlf
a0wollo 1
end - start + 1
b. end start + 6
(( end - start) / 5) + 1
d. 5 * (end - start) + 1
а.
C.
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
Name and Address The Name and Address Problem Write a GUI program that displays your name and address when a bu...
Starting Out with Python (4th Edition)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
A __________ is a component that can connect user interface controls directly to a dataset. a. controller b. so...
Starting out with Visual C# (4th Edition)
System.out.print(I am the incredible); System.out.print(computing\nmachine); System.out.print(\nand I will\nama...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Extreme programming expresses user requirements as stories, with each story written on a card. Discuss the adva...
Software Engineering (10th Edition)
Lottery Winners Modification Modify the program you wrote for Programming Challenge 2 (Lottery Winners) so it p...
Starting Out with C++ from Control Structures to Objects (8th Edition)
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
- True or False? Every if statement must have a corresponding else.arrow_forward! 1000$ by default, but discounts are applied to it based on different criteria. 1- Students get 20% discount. 2- People who purchase in 30 days in advance get 25% discount. 3- student purchasing 40 days in advance gets a 40% discount. This code segment calculates the final price. x = Text1.Text If x= "student" Then 1-... ElseIf x= "advance" Then price 1000 - 0.25 * 1000 ElseIf x= "stu_adv" Then price 1000 - 0.4 * 1000 2-...... price = 1000 3-..... 4-.. O = 1-price = 1000 - 0.2 * 1000 2-Else 3- End If 4-Print price 1-price 1000 - 0.2 * 1000 2-Else 3- Print price 4-End If 1-price = 3-End If 4-Print price = 1000 -0.2 * 1000 2-Elseifarrow_forwardRemaining Time: 54 minutes, 49 seconds. * Question Completion Status: QUESTION 19 Write a Java program that prompts the user to enter the School Grade Level of a student and then calculate their discount amount in the regular fees structure offered during this pandemic situation. By using the below table, calculate their discount amount from the amount of the regular fee and then print the discount amount in OMR by using the appropriate selection structure. (Assume the user is entering a maximum Grade level is 12) discount amount = Regular Fees * percentage of discount rate School Grade Level Regular Fees in OMR Discount Rate >9 and 6 and 3 and 0 and <=3 30.500 5% otherwise 20.400 No discount T T T Arial 3 (12pt) v T -E E- 只i ン Click Save and Submit to save and submit. Click Save All Answers to save all answers. Save All Answers TOSHIBA F5 F6 F7 F8 F9 F10 F11 F12 INS SCNULL LOCK AD & 67 7 V 8A9 4 0arrow_forward
- Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. A student wrote the following code for a guessing game. Line 1: secretNumber RANDOM (1, 100) Line 2: win ← false Line 3: REPEAT UNTIL (win) Line 4: ( Line 5: DISPLAY ("Guess a number.") Line 6: guess INPUT ( ) Line 7: IF (guess = secretNumber) Line 8: ( Line 9: DISPLAY ("You got it right!") Line 10: } Line 11: Line 12: Line 13: ( ELSE IF (guess > secretNumber) Line 14: ( Line 15: DISPLAY ("Your guess is too high.") Line 16: } Line 17: ELSE Line 18: ( Line 19: DISPLAY ("Your guess is too low.") Line 20: } Line 21: } Line 22: } While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction win true somewhere in the code. Where could win true be inserted so that the code segment works as intended? Between line 6 and line 7 Between line 9 and line 10 Between line 20 and 21 Between…arrow_forwardis an operator which can be used for checking if two values are the same.arrow_forwardThe 24-point card game involves picking any four cards from 52 cards, as shown in Figure 10.20. Note that the jokers are excluded. Each card represents a number. An ace, king, queen, and jack represent 1, 13, 12, and 11, respectively. Enter an expression that uses the four numbers from the four selected cards. Each card number can be used only once in each expression, and each card must be used. You can use the operators ( *, and /) and parentheses in the expression. The expression must evaluate to 24. After entering the expression, click the Verify button to check whether the numbers in the expression are currently selected and whether the result of the expression is correct. Display the verification in a dialog box. You can click the Refresh button to get another set of four cards. Assume thatimages are stored in files named 1.gif, 2.gif, ..., 52.gif, in the order of spades, hearts, diamonds, and clubs. So, the first 13 images are for spades 1, 2, 3, ..., and 13.arrow_forward
- VBA - EXCEL Engine – optional – this indicates the solving method that needs to be used to get to a solution. 1 for the Simplex LP method, 2 for the GRG Nonlinear method, or 3 for the Evolutionary method. This corresponds to the Select a Solving Method dropdown list in the Solver Parameters dialog box EngineDesc – optional -this is an alternate way of selecting the solving method – here you would type the strings “Simplex LP”, “GRG Nonlinear” or “Evolutionary”. This also corresponds to the Select a Solving Method dropdown list in the Solver Parameters dialog box What happens when the code demonstrates: Engine:=1, EngineDesc:="GRG Nonlinear" ?arrow_forwardSerendipity Booksellers has a book club that awards points to its customers based on the number of books purchased each month. The points are awarded as follows: If a customer purchases no books, he or she earns 0 points If a customer purchases 1 through 5 books, he or she earns 5 points for each book. If a customer purchases 6 through 10 books, he or she earns 10 points for each book. If a customer purchases 11 or more books, he or she earns points equal to 20 points for each book. (Use Python) Use the Design Recipe to write the function customer_rewards which consumes the number of books purchased, and returns the total points. Include a docstring! Write 3 assert_equal statements to test your function.arrow_forward1): Q: p = F, q = T, and r = T. Select the expression that evaluates to false. Group of answer choices A): ¬q B): q∨r C): q∧r D): p∨r 2): Q: Select the statement that is false. a. If 3 is a prime number, then 5 is a prime number. b.If 4 is a prime number, then 6 is a prime number. c.If 4 is a prime number, then 5 is a prime number. d. If 3 is a prime number, then 6 is a prime number. Group of answer choices d a b carrow_forward
- Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Assign userNum2 with 4 if userNum2 is greater than 9. Otherwise, print "userNum2 is less than or equal to 9.". End with newline. C codearrow_forwardIndicate whether each argument is valid or invalid. If an argument is valid, then the argument uses exactly one of the rules of inference. Indicate which rule is used for the argument. If the argument is invalid, give truth assignments to the propositions "Sally took the medication" and "Sally had side effects" that prove the argument is invalid. Sally had a side effect or Sally took the medication. Sally took the medication. Sally did not have side effects. Invalid. Sally took the medication = F. Sally had side effects = T. Invalid. Sally took the medication = T. Sally had side effects = T. Valid. Addition. Valid. Modus tollens.arrow_forwardExercise I- Medicine Write a program that asks the user to enter the name of the medicine (t for ThroX, f for FeliX), his mass. The user should enter as well if he has a prescription or not. The program will calculate the dosage using: age and his ThroX without prescription -The max dosage should be 0.75 mL -The dosage = mass / 150 -The number of pills per day to take is 1 ThroX with prescription -The dosage =mass * 3 / 150 -The number of pills per day to take is 5 FeliX with prescription -The dosage = 0.77 mL FeliX without prescription -The dosage should be between 0.3 and 0.7 -The dosage = mass * 0.009 -The number of pills per day to take is 2 -The number of pills per day to take is 6 The program should display the dosage and the number of pills to be taken per day if the requirements are full filled, otherwise it display "Please check your doctor for a prescription". In case the medicine does not exist in the database, the program display “Your medicine is not in our database!"…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
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY