Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.4, Problem 6.4.8CP
Write method headers (not the bodies) for the following methods:
- a. Return a sales commission, given the sales amount and the commission rate.
- b. Display the calendar for a month, given the month and year.
- c. Return a square root of a number.
- d. Test whether a number is even, and returning true if it is.
- e. Display a message a specified number of times.
- f. Return the monthly payment, given the loan amount, number of years, and annual interest rate.
- g. Return the corresponding uppercase letter, given a lowercase letter.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
construct 2 methods: Void input() and void maxNum(). The input method should allow user to input 3 integers while maxNum method should be able to generate the highest number. Display the highest number in your program.
Write a program that displays the income tax due on taxable income entered by the user. Have the user enter the tax in the main() method, and then call a calcTax() method to compute the tax. Print the value returned.
The calcTax() method should have one parameter - income - and return a double - tax.
The tax is calculated as follows:
Income
Tax Due
$0 - $50,000
5%
$50,000-$100,000
$2,500 + 10% of (income > $50,000)
> $100,000
$7,500 + 15% of (income > $100,000)
6. Write a method that reads three strings from the keyboard. Although the strings are in no particular order, display the string that would be second if they were arranged lexicographically.
7. Write a method that reads a one-line sentence as input and then displays the following response: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word Yes. If the sentence ends with a question mark and the input contains an odd number of characters, display the word No. If the sentence ends with an exclamation point (!), display the word Wow. In all other cases, display the words You always say followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a…
Chapter 6 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
Ch. 6.4 - What are the benefits of using a method?Ch. 6.4 - Prob. 6.4.2CPCh. 6.4 - How do you simplify the max method in Listing 6.1...Ch. 6.4 - Prob. 6.4.4CPCh. 6.4 - Prob. 6.4.5CPCh. 6.4 - Prob. 6.4.6CPCh. 6.4 - Prob. 6.4.7CPCh. 6.4 - Write method headers (not the bodies) for the...Ch. 6.4 - Identify and correct the errors in the following...Ch. 6.4 - Prob. 6.4.10CP
Ch. 6.5 - Prob. 6.5.1CPCh. 6.5 - Identify and correct the errors in the following...Ch. 6.5 - Prob. 6.5.3CPCh. 6.5 - Prob. 6.5.4CPCh. 6.6 - Prob. 6.6.1CPCh. 6.6 - Prob. 6.6.2CPCh. 6.7 - What is hexCharToDecimal ( B)) ? What is...Ch. 6.8 - What is method overloading? Is it permissible to...Ch. 6.8 - What is wrong in the following program? public...Ch. 6.8 - Given two method definitions, public static double...Ch. 6.9 - Prob. 6.9.1CPCh. 6.9 - What is the scope of a local variable?Ch. 6 - (Math: pentagonal numbers) A pentagonal number is...Ch. 6 - (Sum the digits in an integer) Write a method that...Ch. 6 - (Palindrome integer) Write the methods with the...Ch. 6 - (Display an integer reversed) Write a method with...Ch. 6 - (Sort three numbers) Write a method with the...Ch. 6 - (Display patterns) Write a method to display a...Ch. 6 - (Financial application: compute the future...Ch. 6 - (Conversions between Celsius and Fahrenheit) Write...Ch. 6 - Prob. 6.9PECh. 6 - (Use the isPrime Method) Listing 6.7,...Ch. 6 - (Financial application: compute commissions) Write...Ch. 6 - (Display characters) Write a method that prints...Ch. 6 - (Sum series) Write a method to compute the...Ch. 6 - (Estimate ) can be computed using the following...Ch. 6 - (Financial application: print a tax table) Listing...Ch. 6 - Prob. 6.16PECh. 6 - Sections 6.10 and 6.11 6.17 (Display matrix of 0s...Ch. 6 - (Check password) Some Websites impose certain...Ch. 6 - (Triangles) Implement the following two methods: /...Ch. 6 - (Count the letters in a string) Write a method...Ch. 6 - (Phone keypads) The international standard...Ch. 6 - (Math: approximate the square root) There are...Ch. 6 - (Occurrences of a specified character) Write a...Ch. 6 - (Display current date and time) Listing 2.7,...Ch. 6 - Prob. 6.25PECh. 6 - (Palindromic prime) A palindromic prime is a prime...Ch. 6 - (Emirp) An emirp (prime spelled backward) is a...Ch. 6 - (Mersenne prime) A prime number is called a...Ch. 6 - (Twin primes) Twin primes are a pair of prime...Ch. 6 - (Game: craps) Craps is a popular dice game played...Ch. 6 - (Financial: credit card number validation) Credit...Ch. 6 - (Game: chance of winning at craps) Revise...Ch. 6 - (Current date and time) Invoking System....Ch. 6 - (Print calendar) Programming Exercise 3.21 uses...Ch. 6 - (Geometry: area of a pentagon) The area of a...Ch. 6 - (Geometry: area of a regular polygon) A regular...Ch. 6 - (Format an integer) Write a method with the...Ch. 6 - (Generate random characters) Use the methods in...Ch. 6 - (Geomentry: point position) Programming Exercise...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Figure 4-3212 shows a class list for Millennium College. Convert this user view to a set of 3NF relations using...
Modern Database Management
Circumference and Area of a Circle) Heres a peek ahead. In this chapter, you learned about integers and the typ...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
When placed at the end of an IfThenElself statement, this provides default action when none of the ElseIf state...
Starting Out With Visual Basic (8th Edition)
Determine the reactions at the supports A and B, then draw the shear and moment diagrams. El is constant.
Mechanics of Materials (10th Edition)
Write an SQL statement to display the last name, first name, and email of any owners of cats. Use a subquery. T...
Database Concepts (8th Edition)
Actions taken by the computer when a module is called, such as allocating memory for parameters and local varia...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
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
- A primitive variable is passed from one method to another method by in Java. pass by value O pass by referencearrow_forwarda. Plan the logic for an insurance company program to determine policy premiums. The program continuously prompts the user for an insurance policy number. When the user enters an appropriate sentinel value, end the program. Call a method that prompts each user for the type of policy needed—health or auto. While the user’s response does not indicate health or auto, continue to prompt the user. When the value is valid, return it from the method. Pass the user’s response to a new method where the premium is set and returned—$550 for a health policy or $225 for an auto policy. Display the results for each policy. b.Modify Exercise 9a so that the premium-setting method calls one of two additional methods—one that determines the health premium or one that determines the auto premium. The health insurance method asks users whether they smoke; the premium is $550 for smokers and $345 for nonsmokers. The auto insurance method asks users to enter the number of traffic tickets they have received…arrow_forwardWrite a program that asks the user to enter a character. Then pass the character to the following methods. a) isVowel() – returns true if the character is a vowel b) isConsonant() – returns true if the character is a consonant c) changeCase() – if the character is lower case then change it to upper case and if the character is in upper case then change it to lower case. Example output is given below: Enter a character a a is a vowel a is not a consonant a is equivalent to A Note: Java represents character using Unicode encoding and ‘A’ to ‘Z’ is represented by numbers 65 to 90 and ‘a’ to ‘z’ is represented by numbers 97 to 122. So to convert ‘A’ to ‘a’ you need to add (97-65) to A and then cast it to Character type since the addition will change its type to integer. You can use the following code to read a character from console. When you call charAt(i) method for any String it returns the character at index i. The index of first character is 0, the index of…arrow_forward
- Task 1: Write a Java Program which will determine whether a number is even or odd. Take the number as an input from the user. Perform the checking in a separate method other than main method. Print the results in main method. Task 2: Find out the area of three geometric shape: Circle, Triangle, Square. Give the user an option to select which geometric shape's area he/she wants to find out. Based on the choice take necessary input and find out the result. Use different area method for each geometric shape. Print the result in main method.arrow_forwardWrite a method that finds the average of 4 double numbers. The parameters consist of 4 double numbers read in main and then passed to the method. The method will then return the average to main which will display the value to the user. public static double avg (double a, double b, double c, double d)arrow_forwardUSING PYTHON LANGUAGE A common place to buy candy is from a machine. The machine sells candies, chips, gum, and cookies. You have been asked to write a program for this candy machine.The program should do the following:1. Show the customer the different products sold by the candy machine.2. Let the customer make the selection.3. Show the customer the cost of the item selected.4. Accept money from the customer.5. Release the item.arrow_forward
- 1. Write a program that will ask the a user a number between 1 to 7. 2. Print out the equivalent day of the week for that number. Starting 1 for Sunday, 2 for Monday and etc. 3. Use at least 1 user-defined method aside from your main method in writing a code for this problem (Input number: Expected Output: )arrow_forwardWe need a program that calculates a medicine dosage by age. The following table states the amount of mg according to age ranges: AGE DOSE 1-5 years Greater or equal to 5 (MG) 100 220 Write a method int findDose(int nbyears) that takes the number of years and returns the dose in mg. Write a test program that asks the user to enter the number of years (a positive, non-zero value) and prints the dose.arrow_forwardWrite a program that takes three numbers (a,b,c) from the user as input and finds the median of the three. The program has a method called median that takes 3 numbers as the parameter and returns the median. Use if-then-else statements to find the median. You can assume the three numbers are not the same.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 LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY