In a file called MethodExercises.java. Define the following methods in the file and provide the JavaDoc...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In a file called MethodExercises.java. Define the following methods in the file and provide the JavaDoc for each method. Your instructor will test your program by using a tester, therefore, make sure you follow the instructions for each method definition. A compiled syntax error will provoke that your program will not run effectively resulting in an unsatisfactory grade. In case your method was not implemented and tested effectively, please avoid providing the solution in your lab. You can test your program with the tester located at the website called MethodTester.java. This program will run your program and your professor will be grade your methods based on: Method Functionality • Method header definition specification Method documentation Style and format on your code, and Readability of code Here are the list of methods to be implemented in MethodExercises.java. METHOD DESCRIPTIONS 1. Write a method called print. This method will take a String as an argument and it will print the given String inside the method. 2. Write a method called printNtimes. This method will take two arguments: a String s and a number n. The method will print the giving Strings, the total of n times. 3. Write a method called sum. This method will take two ints as arguments and it will perform the addition of the two values. 4. Write a method called findTheLargest. This method will take two ints as arguments and it will return the largest value from the arguments. 5. Write a method called findTheSmallest. This method will take two ints as arguments and it will return the smallest value from the arguments. 6. Write a method called largestString. The method will take two Strings as arguments. The method shall return the largest String in length. For Example, if string1 is "hello" and the string2 is "good bye" the method shall return "good bye" since the length of "good bye" is 7 and the string "hello" is 5. 7. Write a method called countTotalTimes. The method will take a Strings as an argument and a character c as argument. Your method will count the total number of times the character c appears in the String s. E.g., if String s the char c = 'a', this method will return 3. = "bananas", and 8. Write a method called countASCIIValues. The method will take a String s as an argument and it will calculate the sum of all the characters in the String. E.g., A String is composed of characters, and each character has a ASCII value. If the String s="cow", then 'c' + 'o' + 'w', which is 99 + 111 + 119. Therefore, the method will provide you 329. 9. Write a method called generateRandomBetween. The method will take two integers as parameters, i.e., start and end. The method shall generate a random number between start and end (inclusive). Hint: See Chapter 4 for details on how to use Math.random or the library java.util.Random. 10. Write a method called, findSumRange. The method will take two int numbers as parameters. The purpose of this method is to calculate the sum from all the consecutive numbers both numbers. I.e., if the first number is 3 and the second number is 7, the method will return 25, since 3 +4+5+ 6+ 7 = 25. 11. Write a method called readFile. The method will take a String as parameter representing the name of a file. The purpose of this method is to read a file and print the content of the file. 12. Write a method called writeToFile. The method shall take two Strings as parameter. The first parameter is a String s, and the second parameters is a String f. The String £ is the name of the file. The purpose of this method is to append the string s into the file £. In case the file does not exists, your program shall create it. In a file called MethodExercises.java. Define the following methods in the file and provide the JavaDoc for each method. Your instructor will test your program by using a tester, therefore, make sure you follow the instructions for each method definition. A compiled syntax error will provoke that your program will not run effectively resulting in an unsatisfactory grade. In case your method was not implemented and tested effectively, please avoid providing the solution in your lab. You can test your program with the tester located at the website called MethodTester.java. This program will run your program and your professor will be grade your methods based on: Method Functionality • Method header definition specification Method documentation Style and format on your code, and Readability of code Here are the list of methods to be implemented in MethodExercises.java. METHOD DESCRIPTIONS 1. Write a method called print. This method will take a String as an argument and it will print the given String inside the method. 2. Write a method called printNtimes. This method will take two arguments: a String s and a number n. The method will print the giving Strings, the total of n times. 3. Write a method called sum. This method will take two ints as arguments and it will perform the addition of the two values. 4. Write a method called findTheLargest. This method will take two ints as arguments and it will return the largest value from the arguments. 5. Write a method called findTheSmallest. This method will take two ints as arguments and it will return the smallest value from the arguments. 6. Write a method called largestString. The method will take two Strings as arguments. The method shall return the largest String in length. For Example, if string1 is "hello" and the string2 is "good bye" the method shall return "good bye" since the length of "good bye" is 7 and the string "hello" is 5. 7. Write a method called countTotalTimes. The method will take a Strings as an argument and a character c as argument. Your method will count the total number of times the character c appears in the String s. E.g., if String s the char c = 'a', this method will return 3. = "bananas", and 8. Write a method called countASCIIValues. The method will take a String s as an argument and it will calculate the sum of all the characters in the String. E.g., A String is composed of characters, and each character has a ASCII value. If the String s="cow", then 'c' + 'o' + 'w', which is 99 + 111 + 119. Therefore, the method will provide you 329. 9. Write a method called generateRandomBetween. The method will take two integers as parameters, i.e., start and end. The method shall generate a random number between start and end (inclusive). Hint: See Chapter 4 for details on how to use Math.random or the library java.util.Random. 10. Write a method called, findSumRange. The method will take two int numbers as parameters. The purpose of this method is to calculate the sum from all the consecutive numbers both numbers. I.e., if the first number is 3 and the second number is 7, the method will return 25, since 3 +4+5+ 6+ 7 = 25. 11. Write a method called readFile. The method will take a String as parameter representing the name of a file. The purpose of this method is to read a file and print the content of the file. 12. Write a method called writeToFile. The method shall take two Strings as parameter. The first parameter is a String s, and the second parameters is a String f. The String £ is the name of the file. The purpose of this method is to append the string s into the file £. In case the file does not exists, your program shall create it.
Expert Answer:
Answer rating: 100% (QA)
output Code Commemts added for understanding thanks remember MethodExercisejava and filetxt should b... View the full answer
Related Book For
Business Statistics A Decision Making Approach
ISBN: 9780133021844
9th Edition
Authors: David F. Groebner, Patrick W. Shannon, Phillip C. Fry
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Give the three ways to eliminate the balance in the overhead account at the end of the year.
-
A mean square is the same as what type of descriptive statistic?
-
Senior Home Living (SHL) is a Canadian-based corporation located in British Columbia. SHL provides senior living residences across Canada. The company was incorporated in 1975, and has been...
-
Identify the research scenario, including the general area of focus. Develop a hypothetical research scenario that would necessitate the use of the Action Research Approach and a Posttest With a...
-
Willow Brook National Bank operates a drive-up teller window that allows customers to complete bank transactions without getting out of their cars. On weekday mornings, arrivals to the drive-up...
-
What makes a monetary policy "unconventional"? Make a chronological analysis of advanced economies' monetary policies since the global financial crisis of 2007-2009, including the Covid-19 pandemic...
-
Meriton Ltd borrows $ 100,000 at an interest rate of 11.5% per annum, repayable by equal monthly instalments over 20 years. Calculate the principal and interest components of the first and last...
-
How do intercompany transactions involving bonds and leases interact with the intricacies of capital asset acquisition, maintenance, depreciation, and financing sources in the government and...
-
Question I. What is cross-cultural communication? Briefly explain two principles of cross cultural communication. II. Why cross cultural communication is so important? Identify three barriers to...
-
5. A call option on one share of GM stock with exercise price $80 is trading at $15 and a put option on one share of GM stock with exercise price $80 is trading at 8. Both options will expire one...
-
Below you will find the list of accounts of Limo Belle Services Inc. (in Canadian dollars) September 30, 2012 September 30, 2011 Accumulated Depreciation - limousines Depreciation Expense -...
-
Being first in the industry gives the pioneer added advantages to market share and potential growth. As an example, Nokia retained the top position in the mobile industry courtesy of pioneer or...
-
A sample of 1 mol of monoatomic perfect gas molecules at 500K expands reversibly and adiabatically to thrice its volume. The heat capacity of the gas at constant volume is 12.47 J/ mol K. Calculate...
-
Bobbie Singh provides writing services for small businesses. He blogs for companies that need professionally written content. His business records at November 15, 2023, are shown below: During the...
-
Consider the following sample data for the variables y and x: a. Calculate the linear regression equation for these data. b. Determine the predicted y -value when x = 10. c. Estimate the change in...
-
Develop a multiple regression model containing all four independent variables. Show clearly the regression coefficients. Write a short report discussing the model. In your report make sure you cover...
-
The Hydronics Company is in the business of developing health supplements. Recently, the companys research and development department came up with two weight-loss products that included products...
-
Solve Exercise 1.22 using the concept of the transfer function. Exercise 1.22 Compute the inverse Fourier transform of \[X\left(\mathrm{e}^{\mathrm{j} \omega} ight)=\frac{1}{1-\mathrm{e}^{-\mathrm{j}...
-
We define the even and odd parts of a complex sequence \(x(n)\) as \[\mathcal{E}\{x(n)\}=\frac{x(n)+x^{*}(-n)}{2} \quad \text { and } \quad \mathcal{O}\{x(n)\}=\frac{x(n)-x^{*}(-n)}{2}\]...
-
Prove that \[\begin{equation*}\mathcal{F}^{-1}\left\{\sum_{k=-\infty}^{\infty} \delta\left(\omega-\frac{2 \pi}{N} k ight) ight\}=\frac{N}{2 \pi} \sum_{p=-\infty}^{\infty} \delta(n-N p) \tag{2.262}...
Study smarter with the SolutionInn App