Write a method isEven that uses the remainder operator (%) to determine whether an integer is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a method isEven that uses the remainder operator (%) to determine whether an integer is even. The method should take an integer argument and return true if the in- teger is even and false otherwise. Incorporate this method into an application that inputs a se- quence of integers (one at a time) and determines whether each is even or odd. Q2: (10 points) 6.22 (Temperature Conversions) Implement the following integer methods: a) Method celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation celsius = 5.0 / 9.0 (fahrenheit 32); b) Method fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation fahrenheit = 9.0 / 5.0 celsius+ 32; c) Use the methods from parts (a) and (b) to write an application that enables the user ei- ther to enter a Fahrenheit temperature and display the Celsius equivalent or to enter a Celsius temperature and display the Fahrenheit equivalent. Q3: (10 points) 7.11 Write statements that perform the following one-dimensional-array operations: a) Set the 10 elements of integer array counts to zero. b) Add one to each of the 15 elements of integer array bonus. c) Display the five values of integer array bestScores in column format. Q4: (20 Points) A- Write a method, called findNameIndex, which receives two parameters: 1: an array of type String. called nameArray, 2: a String called name and returns an integer value. B- The method searches the name Array for the given name. If the name matches one of the values stored in the nameArray, the method returns the index of the matched name in the array. If the name is not found in the name Array, the method returns -1. Test your method by writing a Java program that its main method does the following: a) Creates a one-dimensional array, called peopleNames, of type String, and fills the array with the first names of at least 5 people. b) Prints the peopleNames array. c) Calls findNameIndex and passes the people Names array and a first name of type String to the method for the following two cases and prints the result: i- ii- The given name does not exist in the peopleNames array. The given name exists in the peopleNames array. Q5: Write a Java program that performs the following: (20 Points) a) Creates an ArrayList, called al that can store integers. b) Fills the al ArrayList with 10 random integer numbers between 1 and 100. c) Prints the content of al. d) Removes the first element of al. e) Prints the removed element in step d. f) Prints the content of al again. Q4: (10 points) 8.4 (Rectangle Class) Create a class Rectangle with attributes length and width, each of which defaults to 1. Provide methods that calculate the rectangle's perimeter and area. It has set and get methods for both length and width. The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. Write a program to test class Rectangle. Write a method isEven that uses the remainder operator (%) to determine whether an integer is even. The method should take an integer argument and return true if the in- teger is even and false otherwise. Incorporate this method into an application that inputs a se- quence of integers (one at a time) and determines whether each is even or odd. Q2: (10 points) 6.22 (Temperature Conversions) Implement the following integer methods: a) Method celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation celsius = 5.0 / 9.0 (fahrenheit 32); b) Method fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation fahrenheit = 9.0 / 5.0 celsius+ 32; c) Use the methods from parts (a) and (b) to write an application that enables the user ei- ther to enter a Fahrenheit temperature and display the Celsius equivalent or to enter a Celsius temperature and display the Fahrenheit equivalent. Q3: (10 points) 7.11 Write statements that perform the following one-dimensional-array operations: a) Set the 10 elements of integer array counts to zero. b) Add one to each of the 15 elements of integer array bonus. c) Display the five values of integer array bestScores in column format. Q4: (20 Points) A- Write a method, called findNameIndex, which receives two parameters: 1: an array of type String. called nameArray, 2: a String called name and returns an integer value. B- The method searches the name Array for the given name. If the name matches one of the values stored in the nameArray, the method returns the index of the matched name in the array. If the name is not found in the name Array, the method returns -1. Test your method by writing a Java program that its main method does the following: Write a method isEven that uses the remainder operator (%) to determine whether an integer is even. The method should take an integer argument and return true if the in- teger is even and false otherwise. Incorporate this method into an application that inputs a se- quence of integers (one at a time) and determines whether each is even or odd. Q2: (10 points) 6.22 (Temperature Conversions) Implement the following integer methods: a) Method celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation celsius = 5.0 / 9.0 (fahrenheit 32); b) Method fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation fahrenheit = 9.0 / 5.0 celsius+ 32; c) Use the methods from parts (a) and (b) to write an application that enables the user ei- ther to enter a Fahrenheit temperature and display the Celsius equivalent or to enter a Celsius temperature and display the Fahrenheit equivalent. Q3: (10 points) 7.11 Write statements that perform the following one-dimensional-array operations: a) Set the 10 elements of integer array counts to zero. b) Add one to each of the 15 elements of integer array bonus. c) Display the five values of integer array bestScores in column format. Q4: (20 Points) A- Write a method, called findNameIndex, which receives two parameters: 1: an array of type String. called nameArray, 2: a String called name and returns an integer value. B- The method searches the name Array for the given name. If the name matches one of the values stored in the nameArray, the method returns the index of the matched name in the array. If the name is not found in the name Array, the method returns -1. Test your method by writing a Java program that its main method does the following: a) Creates a one-dimensional array, called peopleNames, of type String, and fills the array with the first names of at least 5 people. b) Prints the peopleNames array. c) Calls findNameIndex and passes the people Names array and a first name of type String to the method for the following two cases and prints the result: i- ii- The given name does not exist in the peopleNames array. The given name exists in the peopleNames array. Q5: Write a Java program that performs the following: (20 Points) a) Creates an ArrayList, called al that can store integers. b) Fills the al ArrayList with 10 random integer numbers between 1 and 100. c) Prints the content of al. d) Removes the first element of al. e) Prints the removed element in step d. f) Prints the content of al again. Q4: (10 points) 8.4 (Rectangle Class) Create a class Rectangle with attributes length and width, each of which defaults to 1. Provide methods that calculate the rectangle's perimeter and area. It has set and get methods for both length and width. The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. Write a program to test class Rectangle. a) Creates a one-dimensional array, called peopleNames, of type String, and fills the array with the first names of at least 5 people. b) Prints the peopleNames array. c) Calls findNameIndex and passes the people Names array and a first name of type String to the method for the following two cases and prints the result: i- ii- The given name does not exist in the peopleNames array. The given name exists in the peopleNames array. Q5: Write a Java program that performs the following: (20 Points) a) Creates an ArrayList, called al that can store integers. b) Fills the al ArrayList with 10 random integer numbers between 1 and 100. c) Prints the content of al. d) Removes the first element of al. e) Prints the removed element in step d. f) Prints the content of al again. Q4: (10 points) 8.4 (Rectangle Class) Create a class Rectangle with attributes length and width, each of which defaults to 1. Provide methods that calculate the rectangle's perimeter and area. It has set and get methods for both length and width. The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. Write a program to test class Rectangle.
Expert Answer:
Answer rating: 100% (QA)
Lets go through each of the questions step by step Q1 java import javautilScanner public class EvenOddChecker public static void mainString args Scanner scanner new ScannerSystemin while true Systemou... View the full answer
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
Write a method isDivisible that uses the remainder operator (%) to determine whether ten input integers are divisible by 5 or not. The method should take an integer argument and return true if the...
-
50 successes in 200 trials when p = 0.2. For the binomial experiments find the normal approximation for the probability of
-
Many states that have corporate income taxes "piggyback" onto the Federal corporate income tax calculation. In other words, these states' corporate income tax calculations incorporate many of the...
-
The Chartered Institute of Management Accountants (CIMA) has warned that linking directors pay to EPS or return on assets is open to abuse, since these are not the objective measures they might...
-
A project has been selected for implementation. The net cash flow (NCF) profile associated with the project is shown below. MARR is 10 percent/year. a. What is the internal rate of return of this...
-
Budgeted income statement. (CMA, adapted) Easecom Company is a manufacturer of videoconferencing products. Regular units are manufactured to meet marketing projections, and specialized units are made...
-
Does the market size factor in your decision to expand your company's scale of operations in Canada vs. countries in Asia, such as Indonesia, the Philippines, Malaysia, Thailand, India, Singapore?...
-
1. If Bozena participates and the 401(k) earns 10 percent annually, how much will she have accumulated in 45 years (to age 67) even if her salary does not change? 2. If she does not participate and...
-
When does copyright 'subsist' or come into existence? How is copyright a valuable asset in business?
-
Distinguish and interact with the interrelated functional areas of an organization (operations, human resources, marketing, accounting etc).
-
How does the understanding of societal norms influence healthcare research topics? Provide an example to support your thoughts.
-
Labor rates typically refer to a business's Group of answer choices Hourly or salaried wages paid to employees. Costs incurred for training and development programs. Expense on employee benefits and...
-
write a response to The two fundamental principles for the Germain healthcare system are solidarity and subsidiarity. They are additionally included in Germany's Basic Law of 1949. Solidarity is used...
-
Why do Companies and businesses use job performance evaluation to find how well their employees perform in their respective duties?. Thorough explanation with references. Thank you
-
There are a few friends living in the same area. They have a party every weekend and the place of party change each week. It is always a difficult task to select a place that is nearest to everyone....
-
Explain the regulation of the secretions of the small intestine.
-
Create a class Cylinder with attributes radius and height, each of which has a default value of 1. Provide a method that calculates the cylinders volume, which is pi multiplied by the square of the...
-
Using the statements you wrote in Exercise 3.5, write a complete app that calculates and displays the product of three integers. Data From Problem 3.5 Write declarations, statements or comments that...
-
Modify the application developed in Exercise 7.18 so that it can handle the dealers hand automatically, but the player is allowed to decide which cards of the players hand to replace. The application...
-
Consider a second-order system whose transfer function is in standard form as in Equation 10.7. Assume that the requirements for the system unit-step response are rise time \(t_{\mathrm{r}} \leq 0.1...
-
The transfer function of a dynamic system is given by \[G(s)=\frac{s+4}{s^{5}+2 s^{4}+3 s^{3}+8 s^{2}+4 s+5}\] Determine the stability of the system a. Using Routh's stability criterion without...
-
The unit-step response of a dynamic system is shown in Figure 10.12. Find the transfer function of the system if it can be approximated as \(a /\left(s^{2}+2 \zeta \omega_{n} s+\omega_{n}^{2}...
Study smarter with the SolutionInn App