Solved–Lab 6– Solution

$30.00 $19.00

This lab is intended to help you review the material covered in the course to this point. If you save money in an account that earns interest at an interest rate i, you can compute the amount you will have in the account after t years with the formula futureMoney = presentMoney * (1+i)​t.Prompt the…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

This lab is intended to help you review the material covered in the course to this point.

  1. If you save money in an account that earns interest at an interest rate i, you can compute the amount you will have in the account after t years with the formula futureMoney = presentMoney * (1+i)t.Prompt the user for their present amount of money, the annual interest rate, and the number of years they plan to save, and tell them how much money they will have after that time. Be sure to format the answer correctly (i.e. use dollar sign, comma, and decimal points as appropriate).

Example:

How much money are you investing? 500

What interest rate will your investment earn? .03 How many years do you plan to invest? 25

After 25 years of earning 3% interest your $500 will be worth $1,046.89

  1. Prompt the user for a base number to multiply and the number of multiples of that base number the user wishes to see. Then display the desired number of multiples of the base number. Be careful not to display a comma after the last multiple.

Example:

What number would you like me to multiply? 4 How many multiples of 4 would you like to see? 7

The first 7 multiples of 4 are: 4, 8, 12, 16, 20, 24, 28

  1. Prompt the user to enter as many values as they want. The user should enter the sentinel value 99999to indicate that they are done entering input. Display the average of only the positive values. Completely ignore any negative values when computing the average. Also ignore the 99999value.

Example:

Enter a series of values (enter 99999 to quit):

93 ­4 18 19 ­2 41 17 99999

The average of the positive values is 37.6

  1. In your mainmethod, prompt the user for a number n.Write a method called assessRandomnessthat generates a random number between 1 and 100 ntimes and return the percentage of times the number was less than or equal to 50. Call your assessRandomnessmethod from mainand display the result to the user from main. Do not interact with the user from within the assessRandomnessmethod. The signature of your method should be:

public static double assessRandomness(int n)

Example:

How many random numbers should I generate? 10

<assume the random numbers generated were 11 7 50 61 52 3 92 100 81 66> 40% of the numbers were 50 or less

  1. In your mainmethod, prompt the user to enter ten numbers and store them in an array. Write a method called findthat returns the position of the first occurrence of a particular number in the array. If the number is not in the list, your method should return ‐1. From main,prompt the user to enter a number, call the findmethod, and display the result to the user from main.If the method returned ‐1, inform the user that the number was not in the list. Do not interact with the user from within the findmethod. The signature of your method must be:

public static int find(int[] arr, int thingToFind)

Example:

Enter ten numbers: 18 14 82 17 2 14 6 2 18 4 What number would you like me to find? 2

2 first occurs in the 5th place in the list.

Enter ten numbers: 4 19 0 41 ­2 ­7 7 14 41 100 What number would you like me to find? 99 99 is not in the list.

Rubric

For each question (20 points total):

  • Computes the correct answer: 2 point

  • Complies with all directions: 1 point

  • Follows style guidelines and commented as appropriate: 1 point