Question

I need help with these java codingbat questions please:

Create a method that creates a user id, where the user id is made up of the first letter of the first name and the entire last name. e.g. john smith ->jsmith getUserld(bill, gates)-bgates getUserId(steve, jobs)sjobs getUserId(larry, page) -lpage Go Save, Compile, Run (ctrl-enter) public String getUserId( String firstName, String lastName)

Given a number n, create an array with elements starting from 1 to n. e.g. 5 > getNumArray(1) [1] getNumArray (2) [1, 2] getNumArray(3) - [1, 2, 3] Go Save, Compile, Run (ctrl-enter) public int[] getNumArray(int n)

Given a number n, create an array with odd number starting from 1 to n. e.g. 5 -> getoddNum Array(1) → [1] getoddNumArray(5)- [1, 3, 5] Go Save, Compile, Run (ctrl-enter) public int[] getOddNumArray (int n) t

Get the maximum int value in a given int array getMaxFromArray([1, 2, 3])3 getMaxFromArray([-1, -2, -31)--1 getMaxFromArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 10 Go Save, Compile, Run (ctrl-enter) public int getMaxFromArray intl nums) £

Get the minimum int value in a given int array getMinFromArray([1, 2, 3])1 oetMinF romrayc-i. 3. 0, 9, 10, 23, -10, .50. -2, -3])-3 getMinFromArray([-1, -3, 0, -9, -10, 23, -100, -50, -323])-323 Go Save, Compile, Run (ctrl-enter) public int getHInFromArray( intC] nums)

Get the average from an integer array. getAverage ([1, 2, 3]) 2.0 getAverage([1, 2, 3, 4, 5, 5, 6, 7])- 4.125 getAverage([2, 23, 8, 3, 5, 56, 4565, 12]) 584.25 Go ave, Compile, Run (ctr-enter) how Hint public double getAverage(int[] nums)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public String getUserId(String firstName, String lastName) {
    return firstName.charAt(0) + lastName;
}

public int[] getNumArray(int num) {
    int[] arr = new int[num];
    for(int i = 0; i < num; ++i) {
        arr[i] = i+1;
    }
    return arr;
}

as per guidelines we are only allowed to answer first question Please make separate posts for remaining questions Thanks

Add a comment
Know the answer?
Add Answer to:
I need help with these java codingbat questions please: Create a method that creates a user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write a Java program: Given an array of positive integers, return a count of the...

    Please write a Java program: Given an array of positive integers, return a count of the number of even integers. countEvens([2, 3, 5])-1 countEvens([4, 20]) - 2 countEvens([3, 7, 1, 11]) 0 Go Save, Compile, Run (ctrl-enter) int countEvens (int[] nums) {

  • Has to be in Java programming language Java Python mirrorLength We'll say that a "mirror" section...

    Has to be in Java programming language Java Python mirrorLength We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears in reverse order. For example, the largest mirror section in {1, 2, 3, 8, 9, 3, 2, 1} is length 3 (the {1, 2, 3} part). Return the size of the largest mirror section found in the given array. 3 mirrorLength([1, 2, 3, 8, 9,...

  • This CSIS 9 Python. Java Python Warmup-2 > string_times prev next | chance Given a string...

    This CSIS 9 Python. Java Python Warmup-2 > string_times prev next | chance Given a string and a non-negative int n, return a larger string that is n copies of the original string. string_times('Hi', 2) – 'HiHi' string_times('Hi', 3) - 'HiHiHi' string_times('Hi', 1) – 'Hi' Solution: Go Save, Compile, Run (ctrl-enter) Show Solution def string_times (str, n): def string_times(str, n): result = "" for i in range(n): # range(n) is [0, 1, 2, .... n-1] result = result + str...

  • Two questions, 1) how do I do this, 2) what is wrong with my code norm...

    Two questions, 1) how do I do this, 2) what is wrong with my code norm [email protected] program11 even Positions prev I next chance Given an array of integer values, return a new array consisting only of the elements that have even- numbered indexes. even Positions([7, 51) [7] even Positions([8, 1, 7, 4, 6, 10, 5]) [8, 7, 6, 51 evenPositions([13]) [13] Save, Compile, Run Go int[1 even Positions(int[] nums) int[] newArrays new int[nums. length/2]; for (int i 0; iknums.length;...

  • I'm having trouble making a code for this problem, my class is working with java in...

    I'm having trouble making a code for this problem, my class is working with java in while loops and for loops. Write a method that returns true if an integer parameter n is a perfect number, false otherwise. (recall a perfect number is a number whose sum of its proper factors is equal to itself) (Precondition: n >= 1 .. means you are to presume n is positive) : EXAMPLE: 6 is a perfect number 1 2 3 equals 6...

  • using C++ language!! please help me out with this homework In this exercise, you will have...

    using C++ language!! please help me out with this homework In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...

  • FOR JAVA: Summary: Create a program that adds students to the class list (see below). The...

    FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...

  • In Java: Executable Class create an array of Employee objects. You can copy the array you...

    In Java: Executable Class create an array of Employee objects. You can copy the array you made for Chapter 20. create an ArrayList of Employee objects from that array. use an enhanced for loop to print all employees as shown in the sample output. create a TreeMap that uses Strings for keys and Employees as values. this TreeMap should map Employee ID numbers to their associated Employees. process the ArrayList to add elements to this map. print all employees in...

  • How could I separate the following code to where I have a gradebook.cpp and gradebook.h file?...

    How could I separate the following code to where I have a gradebook.cpp and gradebook.h file? #include <iostream> #include <stdio.h> #include <string> using namespace std; class Gradebook { public : int homework[5] = {-1, -1, -1, -1, -1}; int quiz[5] = {-1, -1, -1, -1, -1}; int exam[3] = {-1, -1, -1}; string name; int printMenu() { int selection; cout << "-=| MAIN MENU |=-" << endl; cout << "1. Add a student" << endl; cout << "2. Remove a...

  • Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method...

    Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT