in java
In a class called DomainParser, write a method getTopLevelDomain that accepts a URL in String format then returns the top level domain.
Files in the same directory:
ComDemo.java
Standard Input:
google.com
Required Output
Enter a String\n Top level domain: com\n
Standard Input
google.co.in
Required Output
Enter a String\n Top level domain: in\n
import java.util.Scanner;
class ComDemo {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a String");
String line = keyboard.nextLine();
System.out.println("Top level domain: " + DomainParser.getTopLevelDomain(line));
}
}
class DomainParser {
public static String getTopLevelDomain(String domain) {
int index = domain.lastIndexOf('.');
if (index == -1) {
return "";
} else {
return domain.substring(index + 1);
}
}
}

in java In a class called DomainParser, write a method getTopLevelDomain that accepts a URL in...
IN JAVA Create a class called Telephone that accepts a phone number in the constructor. For the purposes of this assignment, phone numbers may be any length. Make a method called getPossibilities that returns all possible phonewords for that phone number. A phoneword is what you get when a phone number is converted in to letters. For example, the phone number 922-6966 could be re-written as ZAA-MZNO. Look at your phone to see where those letters came from. DO NOT...
For this question you must write a java class called Rectangle and a client class called RectangleClient. The partial Rectangle class is given below. (For this assignment, you will have to submit 2 .java files: one for the Rectangle class and the other one for the RectangleClient class and 2 .class files associated with these .java files. So in total you will be submitting 4 files for part b of this assignment.) // A Rectangle stores an (x, y) coordinate...
java
/* Q2 (10 pts): Write a method called method that accepts an integer parameter * * * * and returns a sum of the first n terms of the sequence. * In other words, the method should generate the following sequence: 1 + 1/2 + 1/3 + 1/4 + ... 1/n * For example, method2(2) will return 1.5 since 1+1/2 = 1.5 * method2 (15) will return 3.3182289932289937 * You may assume that the parameter n is nonnegative. */...
Write a Java program that has a method called arrayAverage that
accepts an arrary of numbers as an argument and returns the average
of the numbers in that array. Create an array to test the code with
and call the method from main to print the average to the screen.
The array size will be from a user's input (use Scanner).
- array size = int
- avergage, temperature = double
- only method is arrayAverage
Output:
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
By using Java public static methods solve following problem Write a method called vowelCount that accepts a String as its only parameter, and returns an array int[5] containing the count of vowels a,e,i,o,u in that String, using ignoreCase. For example, vowelCount("") returns {0,0,0,0,0}, and for the callvowelCount("Bill Iverson") your method returns {0,1,2,1,0} because there is one 'e' and two 'i' vowels (ignore case) and one 'o' with zero counts for 'a' and 'u' vowels.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: o Write a method called cubeIt that accepts one integer parameter and returns the value raised to the third power as an integer. 2. Write a method called randomInRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. o Write a method called larger that accepts two double parameters and...
Write in Java (10 pts) Write a public method named “Even_Sum” that accepts a one-dimensional array of integers and returns the sum of the even elements in the array (10 pts) Write a public method named “Reverse” that receives a string prints its contents in reverse to the standard output using a stack. Assume the stack has been created and is empty.
In the first task, you will write a Java program that accepts a string of the format specified next and calculate the answer based on the user input. The input string should be of the format dddxxdddxx*, where d represents a digit and x represents any character and asterisk at the end represents that the string can have any number of characters at the end. 1. Prompt the user to enter a string with the specific format (dddxxdddxx*) 2. Read...
java code
Write a method called reverse that takes an array of integers as an input and returns the same values in reverse order as the output. Test your method in the main.