Question

In: Computer Science

(Using Matlab) and "while" function 1.   Write a program that prompts the User for if they...

(Using Matlab) and "while" function

1.   Write a program that prompts the User for if they would like to enter a real number. If yes, prompt the User for the real number. Continue to do this until the User enters “no” to the first question. After the User enters “no”, display the average of all the numbers entered.

(Using Matlab) and "while" function

2.   Write a program that prompts the User for if they would like to enter a real number. If yes, prompt the User for the real number. Continue to do this until the User enters “no” to the first question. After the User enters “no”, display the lowest and the highest number of all the numbers entered.

(Using Matlab) and "while" function

3.   Write a program that calculates how many years it will take to accumulate at least $10,000 in an account if the account starts with $500, and at the end of each year you deposit $500, and the current total earns 5% each year. Report on the number of years it will take, and what the total will be.

(Using Matlab) and "while" function

3.2. above to prompt for the ending amount (instead of $10,000.)

(Using Matlab) and "while" function

3.3. above to also prompt the User for the initial starting value for the account.

(Using Matlab) and "while" function

3.4. above to also prompt the User for the amount to deposit each year.

(Using Matlab) and "while" function

3.5. above to also prompt the User for the interest rate.
(Using Matlab) and "while" function

Solutions

Expert Solution

1_code :

output :

raw_code :

%prompting input or output
real = input('Like to enter a real number[[ y /n] ?: ');
numbers = [];

%using while to repeat
while(real =='y' && real ~= 'n')
num = input('Enter number :');
real = input('Would like to enter a real number : ');
numbers = [numbers ,num];
end

%computinig average
if(length(numbers)>0)
average = sum(numbers)/length(numbers)
end

2_code :

output :

raw_code :

%prompting input or output
real = input('Like to enter a real number[[ y /n] ?: ');
numbers = [];

%using while to repeat
while(real =='y' && real ~= 'n')
num = input('Enter number :');
real = input('Would like to enter a real number : ');
numbers = [numbers ,num];
end

%computinig lowest and highest
if(length(numbers)>0)
lowest = min(numbers)
highest = max(numbers)
end

3_code :

output :

raw_code :

%prompting ending ,initial , deposit ,rate
ending = input('Ending amount : ');
initial = input('Starting vlaue : ');
deposit = input('Deposit per year : ');
rate = input('Interest rate : ');

%using loop to count years to accumulate atleast ending amount
year = 0;
while(ending > initial)
initial = initial + (500*rate/100);
initial = initial + deposit;
year = year +1;
end

%displaying output
fprintf('It will take %d years , for total of $%f\n',year,initial)

**do comment for queries and rate me up****


Related Solutions

Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three...
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three points A, B, and C, namely (xA, yA), (xB, yB), (xC, yC), forming a triangle, storing each in a variable (for a total of 6 variables). The script should then calculate the centroid G = (xG, yG) using xG = xA+xB+xC 3 and yG = yA+yB+yC 3 , storing each in a variable. Finally, the script should print all four points. Sample output: Enter...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer...
write this program in C++ Write a program that prompts a user for three characters. The...
write this program in C++ Write a program that prompts a user for three characters. The program must make sure that the input is a number 10 - 100 inclusive. The program must re prompt the user until a correct input is entered. Finally output the largest and the lowest value. Example 1: Input : 10 Input : 20 Input : 30 The largest is 30. The lowest is 10. Example 2: Input : 100 Input : 50 Input :...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
Write a program that prompts a user for an integer from 1 to 99 and prints...
Write a program that prompts a user for an integer from 1 to 99 and prints it as an amount in words. The program will loop in case the user wants to input an additional number. If the user enters -99, the program will exit. Example: Input: 89 Output: Eighty nine Input: 45 Output: Fourty five Input: -99 Output: Have a nice day. <program exits> For this project, you are to: 1) You should validate any data coming from the...
Problem 1 Write a program that prompts the user to enter an integer It then tells...
Problem 1 Write a program that prompts the user to enter an integer It then tells the user if the integers is a multiple of 2, 3, 5, 7 or none of the above. Program language is C Ex. Enter an integer 12 You entered 12 The number you entered is a multiple of 2 ----------------------------------------------- Enter an integer 11 You entered 11 The number you entered is not a multiple of 2, 3, 5, or 7
Write a program that prompts the user to enter a number within the range of 1...
Write a program that prompts the user to enter a number within the range of 1 to 10 inclusive • The program then generates a random number using the random class: o If the users guess is out of range use a validation loop (DO) to repeat the prompt for a valid number o If the users guess matches the random number tell them they win! o If the users guess does not match the random number tell them they...
Write a program that prompts a user for an integer from 1 to 99 and prints...
Write a program that prompts a user for an integer from 1 to 99 and prints it as an amount in words. The program will loop in case the user wants to input an additional number. If the user enters -99, the program will exit. Example: Input: 89 Output: Eighty nine Input: 45 Output: Fourty five Input: -99 Output: Have a nice day. <program exits> c++ project. need help.
Write a program that prompts the user to enter a number within the range of 1...
Write a program that prompts the user to enter a number within the range of 1 to 10 inclusive • The program then generates a random number using the random class: o If the users guess is out of range use a validation loop (DO) to repeat the prompt for a valid number o If the users guess matches the random number tell them they win! o If the users guess does not match the random number tell them they...
Write a program that prompts the user to enter an integer from 1 to 15 and...
Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid, as shown in the following sample run: here............THE PYRAMID HAS TO BE THIS SHAPE AND IT IS DONE IN JAVA PLEASE 7 6 5 4 3 2 1 2 3 4 5 6 7 6 5 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT