Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed image

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

output Code Commemts added for understanding thanks remember MethodExercisejava and filetxt should b... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Statistics A Decision Making Approach

Authors: David F. Groebner, Patrick W. Shannon, Phillip C. Fry

9th Edition

013302184X, 978-0133021844

More Books

Students also viewed these Programming questions