Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 20.11, Problem 20.11.3CP
If you enter an expression "4 + 5 5 5", the
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Reza Enterprises sells tickets for buses, tours, and other travel services. Because Reza frequently mistypes long ticket numbers, Reza Enterprises has asked his students to write an application that shows if a ticket is invalid. Your application/program tellsthe ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you lose the last digit of the number, then divide by 7, the remainder of the division is exactly the same to the last dropped digit. This process is shown below:
Step 1: Enter the ticket number; for example 123454
Step 2: Remove the last digit, leaving 12345
Step 3: Determine the remainder when the ticket number from step 2 is divided by 7. In this case, 12345 divided by 7 leaves a remainder of 4.
Step 4: Display a message to the ticket agent indicating whether the ticket number is valid or not..
Test your application with the following ticket numbers:
- 123454; is a valid ticket number
- 147103; is a valid ticket number
-…
Write an application that reads an integer and determines and prints whether it’s odd or even. [Hint: Use the remainder operator. An even number is a multiple of 2. Any multiple of 2 leaves a remainder of 0 when divided by 2.]
Please add comments
Chapter 20 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 20.2 - Prob. 20.2.1CPCh. 20.2 - Prob. 20.2.2CPCh. 20.2 - Prob. 20.2.3CPCh. 20.2 - Prob. 20.2.4CPCh. 20.2 - Prob. 20.2.5CPCh. 20.3 - Prob. 20.3.1CPCh. 20.3 - Prob. 20.3.2CPCh. 20.3 - Prob. 20.3.3CPCh. 20.3 - Prob. 20.3.4CPCh. 20.4 - Prob. 20.4.1CP
Ch. 20.4 - Prob. 20.4.2CPCh. 20.5 - Prob. 20.5.1CPCh. 20.5 - Suppose list1 is a list that contains the strings...Ch. 20.5 - Prob. 20.5.3CPCh. 20.5 - Prob. 20.5.4CPCh. 20.5 - Prob. 20.5.5CPCh. 20.6 - Prob. 20.6.1CPCh. 20.6 - Prob. 20.6.2CPCh. 20.6 - Write a lambda expression to create a comparator...Ch. 20.6 - Prob. 20.6.4CPCh. 20.6 - Write a statement that sorts an array of Point2D...Ch. 20.6 - Write a statement that sorts an ArrayList of...Ch. 20.6 - Write a statement that sorts a two-dimensional...Ch. 20.6 - Write a statement that sorts a two-dimensional...Ch. 20.7 - Are all the methods in the Collections class...Ch. 20.7 - Prob. 20.7.2CPCh. 20.7 - Show the output of the following code: import...Ch. 20.7 - Prob. 20.7.4CPCh. 20.7 - Prob. 20.7.5CPCh. 20.7 - Prob. 20.7.6CPCh. 20.8 - Prob. 20.8.1CPCh. 20.8 - Prob. 20.8.2CPCh. 20.8 - Prob. 20.8.3CPCh. 20.9 - How do you create an instance of Vector? How do...Ch. 20.9 - How do you create an instance of Stack? How do you...Ch. 20.9 - Prob. 20.9.3CPCh. 20.10 - Prob. 20.10.1CPCh. 20.10 - Prob. 20.10.2CPCh. 20.10 - Prob. 20.10.3CPCh. 20.11 - Can the EvaluateExpression program evaluate the...Ch. 20.11 - Prob. 20.11.2CPCh. 20.11 - If you enter an expression "4 + 5 5 5", the...Ch. 20 - (Display words in ascending alphabetical order)...Ch. 20 - (Store numbers in a linked list) Write a program...Ch. 20 - (Guessing the capitals) Rewrite Programming...Ch. 20 - (Sort points in a plane) Write a program that...Ch. 20 - (Combine colliding bouncing balls) The example in...Ch. 20 - (Game: lottery) Revise Programming Exercise 3.15...Ch. 20 - Prob. 20.9PECh. 20 - Prob. 20.10PECh. 20 - (Match grouping symbols) A Java program contains...Ch. 20 - Prob. 20.12PECh. 20 - Prob. 20.14PECh. 20 - Prob. 20.16PECh. 20 - (Directory size) Listing 18.10,...Ch. 20 - Prob. 20.20PECh. 20 - (Nonrecursive Tower of Hanoi) Implement the...Ch. 20 - Evaluate expression Modify Listing 20.12,...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What common programming language statement, in your opinion, is most detrimental to readability?
Concepts Of Programming Languages
How is the window manager related to the operating system?
Computer Science: An Overview (12th Edition)
What is denormalization?
Database Concepts (7th Edition)
Geometry Calculator Design a Geometry class with the following methods: A static method that accepts the radius...
Starting Out with Java: From Control Structures through Objects (6th Edition)
Making an instance of one class a member of another class is called _____.
Starting Out with C++: Early Objects (9th 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
- 1. Write a program that lets the user guess whether a randomly generated integer would be even or odd. The program randomly generates an integer and divides it by 2. The integer is even if the remainder is 0, otherwise odd. The program prompts the user to enter a guess and reports whether the guess is correct or incorrect.arrow_forwardQ1: The local Driver's License Office has asked you to write a program that grades the writ- ten portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. A 2. D 3. B 4. B 5. C 6. B 7. A 8. B 9. C 10. D 11. A 12. C 13. D 14. B 15. D 16. C 17. C 18. A 19. D 20. B Your program should store the correct answers shown above in an array. It should ask the user to enter the student's answers for each of the 20 questions, and the answers should be stored in another array. After the student's answers have been entered, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions. Input Validation: Only accept the letters A, B, C, or…arrow_forwardC#arrow_forward
- Program by using C # C sharp My student number :1910206534arrow_forwardAssignment4C: Heads or Tails? It is said that a perfectly fair coin will return heads 50% of the time, and tails 50% of the time. Rather than have you test this theory by flipping a coin yourself, let's use a random number generator and loops to determine the truth. Create a program that prompts the user for a number of coin flips. Then, “flip a coin" that many times by using a random number generator that produces either a 0 or 1. Afterwards, show the user how many times it landed on heads (0) and tails (1) and calculate the frequency for each. Inform the user if heads or tails was the more frequency result, or if they were equal. Call the file name Assignment4C (.java, .cs, .cpp) and the class name Assignment4C. Example outputs are shown below. Note that due to using a random number generator, you may not get the same numerical results – but the formatting and wording should be the same. User input is indicated in bold. Sample Output #1: How many times do you want to flip the coin?:…arrow_forwardPYTHON PROGRAMMING Reza Enterprises sells tickets for buses, tours, and other travel services. Because Reza frequently mistypes long ticket numbers, Reza Enterprises has asked his students to write an application that shows if a ticket is invalid. Your application/program tells the ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you lose the last digit of the number, then divide by 7, the remainder of the division is exactly the same to the last dropped digit. This process is shown below: Step 1: Enter the ticket number; for example 123454 Step 2: Remove the last digit, leaving 12345 Step 3: Determine the remainder when the ticket number from step 2 is divided by 7. In this case, 12345 divided by 7 leaves a remainder of 4. Step 4: Display a message to the ticket agent indicating whether the ticket number is valid or not. If the ticket number is valid, save the number to a .txt file called “tickets.txt” and continue to loop your program…arrow_forward
- C# Write an application that asks the user to enter two integers and displays “The two numbers you entered are: “, followed by the two numbers on the screen. Next , determine the sum, difference (result of first number minus the second number), product, and quotient (result of first number divided by the second number), and modulus (remainder of the first number divided by the second number) and print these values to the screen. Finally, determine the larger of the two integers, and print to the screen “The larger of the two numbers is: “, followed by the larger integer. If the two numbers are equal, print “The two numbers are equal.” Use the example below to format your output.arrow_forwardSlove by pythonarrow_forward1# Write a program that allows users to choose from one of three shapes: Squares, Circles or (right) Triangles. Allow the user to use the first letter of the shape (S, C, T) to specify what they want. After the shape is selected, ask the user for the appropriate data to calculate the shape's area, and then and print that area value to the screen for them. Area formulas you can use: Triangle: % base x height Square: length x length Circle: % Pl x radius? Notes: The floating-point data type will be your friend here. Round your area answer so that no more than 2 decimal places are shown when printing on the screen. You can use 3.1415 for Pl; Think about this as a CONSTANT in your code. For this part and especially part (b) below, think about componentizing your code. So one gigantic main() is not a best practice and not what we want to see here. Remember what we discussed about "procedural decomposition" and functions last week!arrow_forward
- Collatz Sequence: In 1937, Lothar Collatz proposed that no matter what number you begin with, the sequence eventually reaches 1. This is widely believed to be true but has never been formally proved. Write a program that inputs a number from the user, and then displays the Collatz Sequence starting from that number. Stop when you reach 1. If n is even, divide it by 2 to get n / 2. If n is odd, multiply it by 3 and add 1 to get 3n + 1. Repeat the process indefinitely. Find out and print the maximum number that you can get in these calculations. ' Part-3: Please enter a number: 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 The maximum number you get: 9232arrow_forwardFibonacci sequence: The first two numbers of the fibonacci sequence are 1 and 1, and sequential numbers are the sum of the previous two. Write a program that prompts the user for an integer n and then prints the first n numbers of the Fibonacci sequence (Please type answer no write by hend)arrow_forwardPython Programming onlyarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY