Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 9.1, Problem 6STQ
Program Plan Intro
“throw” statement:
- The keyword “throw” is used to throw an exception from the program. It is possible to throw either checked or unchecked exception.
- When an exception is thrown using “throw” keyword, the “try” block ends and the statements inside that block will not get executed. The control directly goes to the subsequent “catch” block whose parameter matches the exception object.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Where is the second part of this assignment
Correct answer only. Code and output screenshot.
Nastia has 2 positive integers An and B. She characterizes that:
The integer is acceptable in case it is detachable by A⋅B;
In any case, the integer is almost acceptable, in case it is detachable by A.
For instance, if A=6 and B=4, the integers 24 and 72 are acceptable, the integers 6, 660 and 12 are almost acceptable, the integers 16, 7 are neither acceptable nor almost great.
Discover 3 unique positive integers x, y, and z to such an extent that precisely one of them is acceptable and the other 2 are almost acceptable, and x+y=z.
Input
The main line contains a solitary integer t (1≤t≤10000) — the number of experiments.
The primary line of each experiment contains two integers An and B (1≤A≤106, 1≤B≤106) — numbers that Nastia has.
Output
For each experiment print:
"Indeed" and 3 distinct positive integers x, y, and z (1≤x,y,z≤1018) to such an extent that precisely one of them is acceptable and the other 2…
Correct the following wrong statements.
All binary operators except for the assignment operators are evaluated as user intention.
Chapter 9 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 9.1 - Prob. 1STQCh. 9.1 - What output would the code in the previous...Ch. 9.1 - Prob. 3STQCh. 9.1 - Prob. 4STQCh. 9.1 - Prob. 5STQCh. 9.1 - Prob. 6STQCh. 9.1 - Prob. 7STQCh. 9.1 - Prob. 8STQCh. 9.1 - In the code given in Self-Test Question 1,...Ch. 9.1 - In the code given in Self-Test Question 1,...
Ch. 9.1 - Prob. 11STQCh. 9.1 - Prob. 12STQCh. 9.1 - Prob. 13STQCh. 9.1 - Prob. 14STQCh. 9.2 - Prob. 15STQCh. 9.2 - Prob. 16STQCh. 9.2 - Prob. 17STQCh. 9.2 - Prob. 18STQCh. 9.2 - Prob. 19STQCh. 9.2 - Prob. 20STQCh. 9.2 - Suppose that, in Self-Test Question 19, we change...Ch. 9.2 - Prob. 22STQCh. 9.2 - Prob. 23STQCh. 9.3 - Prob. 24STQCh. 9.3 - Prob. 25STQCh. 9.3 - Prob. 26STQCh. 9.3 - Prob. 27STQCh. 9.3 - Prob. 28STQCh. 9.3 - Repeat Self-Test Question 27, but change the value...Ch. 9.3 - Prob. 30STQCh. 9.3 - Prob. 31STQCh. 9.3 - Prob. 32STQCh. 9.3 - Consider the following program: a. What output...Ch. 9.3 - Write an accessor method called getPrecision that...Ch. 9.3 - Prob. 35STQCh. 9.4 - Prob. 36STQCh. 9.4 - Prob. 37STQCh. 9.4 - Prob. 38STQCh. 9 - Write a program that allows students to schedule...Ch. 9 - Prob. 2ECh. 9 - Prob. 3ECh. 9 - Prob. 4ECh. 9 - Prob. 5ECh. 9 - Write code that reads a string from the keyboard...Ch. 9 - Create a class Rational that represents a rational...Ch. 9 - Prob. 9ECh. 9 - Suppose that you are going to create an object...Ch. 9 - Revise the class RoomCounter described in the...Ch. 9 - Prob. 12ECh. 9 - Write a class LapTimer that can be used to time...Ch. 9 - Prob. 1PCh. 9 - Prob. 2PCh. 9 - Prob. 3PCh. 9 - Write a program that uses the class calculator in...Ch. 9 - Prob. 3PPCh. 9 - Prob. 7PPCh. 9 - Suppose that you are in change of customer service...Ch. 9 - Write an application that implements a trip-time...
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
- Symbolize the following argument and then determine if it is valid or invalid. Everything is physical. Therefore, it is not the case that there is something which isn’t physical.arrow_forwardWhat happens if we receive a type error?arrow_forwardWrite a C++ code based on the Sample Dialog Validate input. Offer to "Try Again". SAMPLE DIALOG: This is just a sample dialog. Code must have an input for number of team, team name, course, & score. ------------------------------- CODING CHALLENGE RESULTS Number of Teams(6-10): 6 ENTER TEAM DETAILS BELOW... Team 1------------------------- Team Name(No space): HariCode Course(IT/CS/IS/CE): CE Team Score(50..100): 65 Team 2------------------------- Team Name(No space): HariDevs Course(IT/CS/IS/CE): CS Team Score(50..100): 90 Team 3------------------------- Team Name(No space): JavaNiceDay Course(IT/CS/IS/CE): IS Team Score(50..100): 75 Team 4------------------------- Team Name(No space): ITwizards Course(IT/CS/IS/CE): IT Team Score(50..100): 70 Team 5------------------------- Team Name(No space): DigitalKraze Course(IT/CS/IS/CE): CS Team Score(50..100): 85 Team 6------------------------- Team Name(No space): BinaryCode Course(IT/CS/IS/CE): IS Team Score(50..100):…arrow_forward
- Java Instructions In this assignment, you will take one Infix expression as input and convert it to both Postfix expression, and Prefix expression Next, you will display the converted versions. See the example below. Finally, you will evaluate the expression, and print out the solution. See the example below. You can assume only integer numbers, +-*/ operators and parentheses are part of the input expression. However, the evaluated output should be of double type. The characters in the input and the output expressions will be separated by single spaces. See the example below. Please follow the same output pattern as shown below. Note: The test run below is just a sample. It does not imply that I will test your code with only this particular input. Make sure you thoroughly test your code before submitting it. Hints You can use Stacks for this task. You can take the input as a string by reading the line from the console. You only need to solve the problem for one input…arrow_forwardThe following PThreads code is written for book reservation in a library. Each student checks if the book is free. If it was free they will reserve it with their own ID and the book becomes unavailable to the rest. a. Can you identify the problem with this code? Explain the condition that the code may fail. b. Rewrite the code (just a few lines of code) to solve the problem. //PThreads code here if (book.state==free) ( book.state%-reserved; book.borrower%=MyID;arrow_forwardGiven: boolean test; char x; Use a Character class method, to write a Java statement to assign true to test if x character is a letter. Note: Do not use if statement here. TTT Arial v 3 (12pt) Click Save and Submit to save and submit. Click Save All Answers to save all answers.arrow_forward
- A retail company assigns a $5000 store bonus if monthly sales are $100,000 or more. Additionally, if their sales exceed 125% or more of their monthly goal of $90,000, then all employees will receive a message stating that they will get a day off. Step 3: Complete the pseudocode by writing the missing lines. When writing your modules and making calls, be sure to pass necessary variables as arguments and accept them as reference parameters if they need to be modified in the module. (Reference: Writing a Decision Structure in Pseudocode, page 118). Module main () //Declare local variables Declare Real monthlySales //Function calls Call getSales(monthlySales) ______________________________________________________ ______________________________________________________ End Module //this module takes in the required user input Module getSales(Real Ref monthlySales) Display “Enter the total sales for…arrow_forwardPart 2 - OddOrEven ClassIn bluej. Write a program that prompts the user to enter an integer. The program should display “The input is odd" to the screen if the input is odd and displays “The input is even" to the screen if the input is even. Hint: Consider using the mod (%) operator.arrow_forwardIn this exercise you will use if and else statements to write some code that simulates a gambler who makes various wagers. As part of your solution, you will use the following parameters that are passed in to the method:A double variable with the identifier money that indicates how much money the gambler has.A double variable with the identifier wager that indicates how much money is being wagered in a particular bet.A Boolean variable with the identifier outcome that indicates if the gambler wins (true) or loses (false)1) In some cases the gambler is unable to fix the outcome of the wager ahead of time and must rely on luck.Use an if statement to check if outcome has a value (whether or not it is null)If it does not have a value, you will need to assign it one by instantiating a Random object and using one of its methods.2) Use an if/else statement to determine if the gambler has won the wager (outcome is true) If the gambler has won the wager, add the wager to amount of money the…arrow_forward
- List the operators that cannot be overloaded.arrow_forwardFix any errors that you find. Use in-line comments to explain how and why you fixed the bugs. Test your program. If you found and fixed all the errors, your code should function as specified: The code should allow users to enter basic, one operator arithmetic expressions using integers or doubles. Then, it should calculate the result of the expression and output the results. For example, if the user inputs “2 + 2,” the calculator should output “2 + 2 = 4.” The operations the program should perform are addition (+), subtraction (-), multiplication (*), and division (/). The user should be asked whether they wish to continue after evaluating each expression. If the user types “Y” or “y,” the program should ask for a new arithmetic expression. If the user types “N” or “n,” the program should terminate with the message: “Program Finished.”arrow_forwardDo not use regular expressions in your solution for this exercise. Write a program that checks to see if an input password is valid or not. In this exercise, a valid password has the following characteristics: It contains at least eight characters. It contains at most 12 characters. It contains only alphabetic characters, digits and the underscore (‘_’) character. It does not start with a digit. It has a mix of upper-case and lower-case characters. Your class must contain the following method: public static String checkPassword(String input) This method receives a possible password as input and returns only the String“OK” if the password is valid. If the password is not valid then you can return the reason(s) for that as the return value. This is not a part of the requirements, however, and you don’t need to do that. You can simply return null for an invalid password.arrow_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 LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher: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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning