Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 1, Problem 3P
Explanation of Solution
Purpose of the given code:
The given code is to product the two numbers and displays the result.
Syntax error:
An error which is occurred on the source code of a program is referred as “syntax error”; because the computer programs are strictly follows the syntax rules, if the code fails to prove its language syntax format then the compiler will throws an error.
Error in the given code:
n1=keyboard.nextInt();
n2=keyboard.nextInt();
The variables “n1” and “n2” are not declared in the given statement. Hence, it throws the syntax error.
Corrected code:
//Import required package
import java.util...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Using the Python language answer the following questions below. Please tell me what program you use if it is IDLE or Atom or a python website please provide the website you use.
Art.java
In this part you will create a program Art.java that produces a recursive drawing of the design attached in the picture.
Requirements
Art.java must take one (1) integer command-line argument n that controls the depth of recursion.
Your drawing must stay within the drawing window when n is between 1 and 7. (The autograder will not test values of n outside of this range.)
You may not change the size of the drawing window (but you may change the scale). Do not add sound.
Your drawing can be a geometric pattern, a random construction, or anything else that takes advantage of recursive functions.
Optionally, you may use the Transform2D library you implemented in Part 1. You may also define additional geometric transforms in Art.java, such as sheer, reflect across the x- or y- axis, or rotate about an arbitrary point (as opposed to the origin).
Your program must be organized into at least three separate functions, including main(). All functions except main() must be private.
call…
Instructions
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
An example of the program is shown below:
Enter name Juan Hello, Juan!
Task 1: The DebugThree3 class compiles without error.
Task 2: The getName() method accepts user input for a name and returns the name value as a String.
Task 3: The displayGreeting() method displays a personalized greeting.
Task 4: The DebugThree3 program accepts user input and displays the correct output.
Chapter 1 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 1.1 - What are the two kinds of memory in a computer?Ch. 1.1 - What is software?Ch. 1.1 - What data would you give to a program that...Ch. 1.1 - What data would you give to a program that...Ch. 1.1 - What is the difference between a program written...Ch. 1.1 - Is Java a high-level language or a low-level...Ch. 1.1 - Is Java bytecode a high-level language or a...Ch. 1.1 - What is a compiler?Ch. 1.1 - What is a source program?Ch. 1.1 - What do you call a program that translates Java...
Ch. 1.2 - What would the following statement, when used in a...Ch. 1.2 - Write a statement or statements that can be used...Ch. 1.2 - Prob. 13STQCh. 1.2 - What is the meaning of the following line in the...Ch. 1.2 - Write a complete Java program that uses system....Ch. 1.2 - Suppose you define a class named YourClass in a...Ch. 1.2 - Prob. 17STQCh. 1.3 - What is a method?Ch. 1.3 - Prob. 19STQCh. 1.3 - Do all objects of the same class have the same...Ch. 1.3 - Prob. 21STQCh. 1.3 - Prob. 22STQCh. 1.3 - Prob. 23STQCh. 1.3 - Prob. 24STQCh. 1.3 - What is an algorithm?Ch. 1.3 - What is pseudocode?Ch. 1.3 - Prob. 27STQCh. 1.3 - Prob. 28STQCh. 1.3 - Prob. 29STQCh. 1.3 - Prob. 30STQCh. 1.3 - Prob. 31STQCh. 1.3 - Suppose you write a program that is supposed to...Ch. 1.4 - Prob. 33STQCh. 1.4 - Prob. 34STQCh. 1 - How does a computers main memory differ from its...Ch. 1 - Prob. 2ECh. 1 - Prob. 3ECh. 1 - How does machine language differ from Java?Ch. 1 - What would the following statements, when used in...Ch. 1 - Write a statement or statements that can be used...Ch. 1 - Write statements that can be used in a Java...Ch. 1 - Given a persons year of birth, the Birthday Wizard...Ch. 1 - Write statements that can be used in a Java...Ch. 1 - Prob. 11ECh. 1 - Prob. 12ECh. 1 - Prob. 13ECh. 1 - Prob. 14ECh. 1 - What attributes and behaviors would an object...Ch. 1 - Suppose that you have a numberxthat is greater...Ch. 1 - Prob. 17ECh. 1 - Prob. 18ECh. 1 - Prob. 19ECh. 1 - Prob. 20ECh. 1 - Obtain a copy of the Java program shown in Listing...Ch. 1 - Modify the Java program described in Practice...Ch. 1 - Prob. 3PCh. 1 - The following program will compile but it has...Ch. 1 - Programming Projects require more problem-solving...Ch. 1 - Write a complete program for the problem described...Ch. 1 - Prob. 3PPCh. 1 - Prob. 4PPCh. 1 - Write an applet program for the problem described...Ch. 1 - Prob. 6PP
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
- Can anyone help solving this problem In Pythonarrow_forwardTranscribed Image Text Python Development Lab In Merworld there exists 2 coins of different denominations types 5-peso coins and 10- peso coins, both having two faces with image of – Elon Musk and a dog. You are assigned a task to find out the number of ways to arrange these coins so that their sum is N pesos. Arrangement should be done in such a way that the first coin in the arrangement should always have Elon Musk image up. Other coins could have any image. Input Output 1 60 5 LOarrow_forwardEdit only the class definition. DO NOT CHANGE the code given under 'main' please. Steps: Additionally implement any Python Magic/Dunder methods such that instances of the class minimally:1. Support addition, subtraction, equality operations and the built-in abs function2. Are Iterable i.e., support for loops and star arguments for unpacking into function calls3. Support a string representation that displays the class name and coordinates stored by the instance: i.e. for an object initialized as: Vector(0, 3), the string representation should be ‘Vector(0, 3)’The code given under main tests for each of the program requirements and subsequently uses the turtle module to plot randomly generated points rotated. A screenshot for a sample run of the program is attached. Template.py: from math import hypot, pi from random import uniform import turtle as t class Vector2D: ... if __name__ == '__main__': # Test Vector class a, b = Vector2D(0, 3), Vector2D(0, -3) tests =…arrow_forward
- Word Statistics: The second requirement change is to allow replacement of all occurrences of a given word to a given replacemWrite the code only in python language with the opeartion exactly and necessary comments to be added.arrow_forwardplease code in python You place a pawn at the top left corner of an n-by-n chess board, labeled (0,0). For each move, you have a choice: move the pawn down a single space, or move the pawn down one space and right one space. That is, if the pawn is at position (i,j), you can move the pawn to (i+1,j) or (i+1, j+1). Ask the user for the size of a chessboard, n (integer). Find the number of different paths starting from (0,0) that the pawn could take to reach each position on the chess board. For example, there are two different paths the pawn can take to reach (2,1). Look at the diagrams below to convince yourself of this. You can see the four paths that you can take by move 2. Start -> Move 1 -> Move 2 (0,0) -> (1,0) -> (2,1) (0,0) -> (1,0) -> (2,0) (0,0) -> (1,1) -> (2,1) (0,0) -> (1,1) -> (2,2) Print the board with the number of ways to reach each square labeled as shown below. For example: Enter a board size: 4 1 0 0 0 1 1 0 0 1 2 1 0 1 3 3 1arrow_forwardcan you do it in python, thank you.arrow_forward
- Create java program by inserting; a. Constructor b. Input from keyboard c. Dialog Box d. Array e. Loop(if applicable) f. Parse method g. Inheritancearrow_forwardImplement using python progeam 1) The Variables used here are as followes B : True if there is a Baseball Game on TV, False if not G: True if George watches TV, False if not C: True if George is out of Cat Food, False if not F: True if George feeds his cat, False if not. Let us say you are given some Training Data which represents what happens over a period of time (For example: This file contains what happens every evening over one specific year). Your Task is to learn the conditonal probabilty tables for the bayesian network from the training data. The training data will be formatted as follows: The first number is 0 if there is no baseball game on TV (B is false), and 1 if there is a baseball game on TV (B is true). The second number is 0 if George does not watch TV (G is false), and 1 if George watches TV (G is true). The third number is 0 if George is not out of cat food (C is false), and 1 if George is out of cat food (C is true). The fourth number is 0 if George does not feed…arrow_forwardwith python do whis: Edit or delete a user profileWhen the user chooses 2, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is passed to the function (i.e., the user chose option 1 before choosing option 2), the program should show the user the following menu:Hello (user name)You can perform one of the following operations:1) Delete your profile2) Edit your profilea. If the user chooses 1, perform the following subtasks to delete a user profile:1- Search for the user profile in the file userInformation.txt using the user name in read mode; once you find the user profile (i.e., the line that contains all the user information), pass it to a function that deletes the user information.2- The function should create a temporary file called temp.txt in write mode and search the file userInformation.txt in read mode…arrow_forward
- python language. Instructions are given within the quotations. def is_word_from_letters(word, letters): """ Returns True if word is spelled by rearrange all or some of the letters Otherwise returns False Notes: this is different from uses_only function we wrote before, word not only can use only characters in letters, but the number of times it can use a letter is also limited by what is in letters. For example: is_word_from_letters("book", "bok") should be False because we do not have enough letter 'o'. """ return Truearrow_forwardPlease code in python Forbidden concepts: recursion, custom classes Create a program that takes a university student’s name, their 1st parent’s income, and their second parent’s income. If the average income between the parents is $40,000 or below, then it would put them into a Tuition Grant list. If it’s above, then it would be a Full Tuition Required list. Once the university admission officer has completed inputting all the students, the program will end and print out the two lists.arrow_forwardPart III - Create Your Own Art Art.java In this part you will create a program Art.java that produces a recursive drawing of your own design. This part is meant to be fun, but here are some guidelines in case you're not so artistic. Requirements Art.java must take one (1) integer command-line argument n that controls the depth of recursion. Your drawing must stay within the drawing window when n is between 1 and 7. (The autograder will not test values of n outside of this range.) You may not change the size of the drawing window (but you may change the scale). Do not add sound. Your drawing can be a geometric pattern, a random construction, or anything else that takes advantage of recursive functions. Your program must be organized into at least three separate functions, including main(). All functions except main() must be private. For full credit, Art.java must not be something that could be easily rewritten to use loops in place of recursion, and some aspects of the recursive…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning