[SOLVED] JAVA Week 3

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon BackEndClass-main-hvrenp.zip (7414.2 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

Instructions: In Eclipse, or an IDE of your choice, write the code that accomplishes the objectives listed below. Ensure that the code compiles and runs as directed. Take screenshots of the code and of the running program (make sure to get screenshots of all required functionality) and paste them in this document where instructed below. Create a new repository on GitHub for this week’s assignments and push this document, with your Java project code, to the repository. Add the URL for this week’s repository to this document where instructed and submit this document to your instructor when complete.

Coding Steps:

  1. Create an array of int called ages that contains the following values: 3, 9, 23, 64, 2, 8, 28, 93.
    1. Programmatically subtract the value of the first element in the array from the value in the last element of the array (i.e. do not use ages[7] in your code). Print the result to the console.
    2. Add a new age to your array and repeat the step above to ensure it is dynamic (works for arrays of different lengths).
    3. Use a loop to iterate through the array and calculate the average age. Print the result to the console.
  2. Create an array of String called names that contains the following values: “Sam”, “Tommy”, “Tim”, “Sally”, “Buck”, “Bob”.
    1. Use a loop to iterate through the array and calculate the average number of letters per name. Print the result to the console.
    2. Use a loop to iterate through the array again and concatenate all the names together, separated by spaces, and print the result to the console.
  1. How do you access the last element of any array?
  2. How do you access the first element of any array?
  3. Create a new array of int called nameLengths. Write a loop to iterate over the previously

    created names array and add the length of each name to the nameLengths array.

  4. Write a loop to iterate over the nameLengths array and calculate the sum of all the

    elements in the array. Print the result to the console.

  5. Write a method that takes a String, word, and an int, n, as arguments and returns the word

    concatenated to itself n number of times. (i.e. if I pass in “Hello” and 3, I would expect

    the method to return “HelloHelloHello”).

  6. Write a method that takes two Strings, firstName and lastName, and returns a full name

    (the full name should be the first and the last name as a String separated by a space).

  7. Write a method that takes an array of int and returns true if the sum of all the ints in the

    array is greater than 100.

  8. Write a method that takes an array of double and returns the average of all the elements

    in the array.

  9. Write a method that takes two arrays of double and returns true if the average of the

    elements in the first array is greater than the average of the elements in the second array.

  10. Write a method called willBuyDrink that takes a boolean isHotOutside, and a double

    moneyInPocket, and returns true if it is hot outside and if moneyInPocket is greater than

    10.50.

  11. Create a method of your own that solves a problem. In comments, write what the method

    does and why you created it.

Screenshots of Code:

Screenshots of Running Application:

URL to GitHub Repository:

GitHub Link

https://github.com/geraldinedepaul17/BackEndClass/blob/main/Work.java

  • BackEndClass-main-hvrenp.zip