Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the provided program Assignment1Functions.java , complete each method. Each static method includes instructions for completing said method in the form of a comment located

In the provided program Assignment1Functions.java, complete each method. Each static method includes instructions for completing said method in the form of a comment located above the method. All methods should be executed in the main method, with their return values printed out when necessary.

 public class Assignment1Functions { /* * Use this main method to test your created methods below. * Just remember for the methods where you return something you need * to print it out in the main method to visualize what happened. * * Unless specified in the instructions DO NOT print in the problem methods below. */ public static void main(String[] args) { } /* * Write a method called "swapHalves" which receives a String as a * parameter, cuts the String in half * and returns a new String with the two halves swapped. */ public static String swapHalves(String line){ // your code goes here } /* * Write a method called "countVowels" which receives a String as a parameter * and returns the number of vowels in the string. */ public static int countVowels(String line){ // your code goes here } /* * Write a method called "getMax" which receives an integer array as a parameter * and returns the max integer in the array. */ public static int getMax(int[] array){ // your code goes here } /* * Write a method called "isPalindrome" which receives a String as a parameter * and returns true if the parameter is a palindrome and false if it is not. * * You can use recursion or an iterative solution. */ public static boolean isPalindrome(String line) { // your code goes here } /* * Write a method called "factorial" which receives an integer as a parameter * and returns the factorial of the given parameter integer. * Remember: 5! (5 factorial) is just 5*4*3*2*1. * * You can use recursion or an iterative solution. */ public static int factorial(int n) { // your code goes here } /* * Write a method called "getFibonacci" which receives an integer as a parameter * and return an array of integers that contains the sequence of fibonacci numbers * up to the index given as the integer parameter. * * Example: If 6 is given you should return the array [0,1,1,2,3,5] */ public static int[] getFibonacci(int n) { // your code goes here } /* * Pythagoras Theorem: a^2 + b^2 = c^2 * Write a method called "getC" which receives two integers as parameters * and returns the hypotenuse of the two parameters as a double. */ public static double getC(int a, int b) { // your code goes here } /* * Write a method called "getWeather" that receives two parameters, * one parameter is going to be a boolean to determine if it's raining or not, * the other parameter is going to be an integer and will be the temperature. * * The method will return the a string explaining the current * state of the weather depending on the parameters. * If it is raining and the temperature is below 30 return "Snowy". * If it is raining and the temperature is not below 30 return "Rainy". * If it is not raining and the temperature is below 30 return "Chilly". * If it is not raining and the temperature is not below 30 return "Sunny". */ public static String getWeather(boolean rain, int temperature) { // your code goes here } /* * Write a method called "containsChar" that receives two parameters, * a string and a char, return true if the string parameter contains * the char parameter and return false if it does not. */ public static boolean containsChar(String line, char x) { // your code goes here } /* * Write a method called "printOdd" that receives an integer array as a parameter. * The method must print every odd integer using System.out.print() and NOT System.out.println(). */ public static void printOdd(int[] array) { // your code goes here } /* * Write a method called "reverseString" that receives a string as a parameter. * return the reversed string. */ public static String reverseString(String line) { // your code goes here } /* * Write a method called "swap" that receives three parameters. One parameter is an integer * array, the other two integers parameters are indexes in the given array. * Swap the values in the array at the two given indexes. Return the new updated array. */ public static int[] swap(int[] array, int index1, int index2) { // your code goes here } /* * Write a method called "reverseInt" that receives an integer as a parameter. * Return the reversed integer without changing the integer into a String. * * Example: If the number given is 5124 the method will return 4215. */ public static int reverseInt(int number) { // your code goes here } /* * Write a method called "rotateArray" that receives an integer array as a parameter. * The method must move every integer in the array to the right one. For example: * The element at index 0 (array[0]) is moved to index 1, the old element at index 1 is moved to index 2 so on. * When you reach the end of the array move the element at that index to index 0 to loop back around. * Return the new rotated array. */ public static int[] rotateArray(int[] array) { // your code goes here } }

I NEED THIS ASAP

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Compare and contrast power, authority, and leadership.

Answered: 1 week ago

Question

2. What, according to Sergey, was strange at this meeting?

Answered: 1 week ago