Question 1: Java Fundamentals

Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase:

  • The number of shares that Joe purchased was 1,000.
  • When Joe purchased the stock, he paid $32.87 per share.
  • Joe paid his stockbroker a commission that amounted to 2% of the amount he paid for the stock.

Two weeks later Joe sold the stock. Here are the details of the sale:

  • The number of shares that Joe sold was 1,000.
  • He sold the stock for $33.92 per share.
  • He paid his stockbroker another commission that amounted to 2% of the amount he received for the stock.

Write a program that displays the following information:

  • The amount of money Joe paid for the stock.
  • The amount of commission Joe paid his broker when he bought the stock.
  • The amount that Joe sold the stock for.
  • The amount of commission Joe paid his broker when he sold the stock.
  • Display the amount of profit that Joe made after selling his stock and paying the two commissions to his broker. (If the amount of profit that your program displays is a negative number, then Joe lost money on the transaction.)

Question 2: Nested Loops

Write a program that use Nested Loop to collect data and calculate the average rainfall over a period of years. First the program should ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, the average rainfall per month for the entire period. Input Validation: Do not accept a number less than 1 for the number of years, do not accept negative numbers for the monthly rainfall.

Question 3: 2D Array

Write a program that lets the user enter four quarterly sales figures for six divisions of a company. The figures should be stored in a two-dimensional array. Once the figures are entered, the program should display the following data for each quarter:

  • A list of the sales figures by division
  • Each division's increase or decrease from the previous quarter (this will not be displayed for the first quarter)
  • The total sales for the quarter
  • The company's increase or decrease from the previous quarter (this will not be displayed for the first quarter)
  • The average sales for all divisions that quarter
  • The division with the highest sales for that quarter

Input Validation: Do not accept negative numbers for sales figures.

Question 4: Strings

Write a program that has two parallel arrays of String objects. One of the arrays should hold people's names and the other should hold their phone numbers.

Here are example contents of both arrays:

name Array Example Contents
"Harrison, Rose" "James, Jean" "Smith, William" "Smith, Brad"

phone Array Example Contents
"555-2234" "555-9098" "555-1785"
"555-9224"

The program should ask the user to enter a name or the first few characters of a name to search for in the array. The program should display all of the names that match the user's input and their corresponding phone numbers. For example, if the user enters "Smith", the program should display the following names and phone numbers from the list:

Smith, William: 555-1785 Smith, Brad: 555-9224
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.