Question

In: Computer Science

I need to ask a user what numbers they want to enter. They can enter as...

I need to ask a user what numbers they want to enter. They can enter as many as they like. Then inside I need to use conditionals to determine if the numbers are <=20, <=323 && > 30, >200. I can't figure out how to let the user enter as many inputs as they want. I know I need to use a loop to check each number entered and determine if it is small middle or greater but I can't figure that out. I want to display at the end each value they have entered and next to that say if it is greater small or middle. Here is what I got so far. THIS IS USING MATLAB

function num = wells(orval)

orval = input('Enter numbers: ');

for i = length(orval)

if i <= 20

disp('small')

elseif i <= 323 & i > 30

disp('middle')

elseif i > 200

disp('greater')

end

end

Solutions

Expert Solution

Answer

Here is your matlab code. I created below code based on the above information. So any doubt please comment i am here to helpy you. Any updation needed please comment.

Here is your matlab code

function wells()  //removed orval parameter because we ask user inside the function
while(1) //infinite while loop user can enter infintite time until he enter -1.
    orval = input('Enter numbers: ');
    if orval==-1
        break
    end
    if orval <= 20
       disp('small')
    else if orval <= 323 & orval > 30 
            disp('middle')
    else if orval > 324 //you said 200, that never execute , so i used above 323 for greater
            disp('greater')

    end
    end
    end
end
end

output

Any doubt please comment, i am here to help you. The code is only based on the question you have given. Any updation please comment

Thanks in advance


Related Solutions

Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
for python 3 a. Ask the user to enter 10 numbers. Each number is stored in...
for python 3 a. Ask the user to enter 10 numbers. Each number is stored in a list called myList. Compute and print out the sum and average of the items in the list. Print the numbers that are divisible by 2 from myList. b. Instead of using a list to store the numbers, create a loop to accept the numbers from the user, and find the average of all the numbers. Hint: use an accumulator to store the numbers...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The program will use a while loop to let the program keep running. The user will be allowed to use the program as long as the quitVariable is equal to 'y' or 'Y'. When the user decides to quit playing, say "Thanks for playing!". The program will use a for loop to test if the number are even or odd. If even print "number is...
write a program i java that ask the user to enter salary, user ID and username...
write a program i java that ask the user to enter salary, user ID and username and out put them
Write a program in Java to: Ask the user how many scores they want to enter...
Write a program in Java to: Ask the user how many scores they want to enter (=> Create an array based the entered size) Ask the user to enter their scores in the quarter (Fill the array with the entered scores(assigned to elements)) ==>> Use a "for" loop Find the greatest score Calculate and show the average Show the final grade based on the average (For example A,B,C ... ) Print the scores (the elements of the array) => Use...
I have to create a program in C++ where a user can enter as many numbers...
I have to create a program in C++ where a user can enter as many numbers as they want (they predetermine the number of values to be inputted) and then the program can echo that input back to the user and then determine if the numbers were even, odd, or a zero and it outputs how many of each were found. This is to be down with four void functions and no arrays. The program initializes the variables zero, odds,...
In MatLab 1. Ask the user to enter a 1 x 5 vector of numbers. Determine...
In MatLab 1. Ask the user to enter a 1 x 5 vector of numbers. Determine the size of the user entry. 2. Ask the user to enter a 1 x 5 vector of numbers. Determine the size of the user entry. If the user enters a 5 x 1 vector, use a warning statement to inform the user of their error, and set the new input value to be the transpose of the user input value. If the user...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that in array. Display that all numbers before and after performing Bubble sort. You must have to create new function with required parameter to perform Bubble sort. Sample Run :- Enter 1 number :- 1 Enter 2 number :- 5 Enter 3 number :- 7 Enter 4 number :- 45 Enter 5 number :- 90 Enter 6 number :- 6 Enter 7 number :- 55...
Task 1. creating a nested if:   Need a python program that ask the user to enter...
Task 1. creating a nested if:   Need a python program that ask the user to enter the annual income of an employee and the years of experience. Pass these data to a function. The function decides if an employee does qualify for a loan or does not, then it prints a message based on the following rules: If the income is equal or greater than $40000, the function checks if the employee's years of experience is greater than 4, if...
C++ Programa that: // 1) Ask the user to enter two numbers greater than zero. Store...
C++ Programa that: // 1) Ask the user to enter two numbers greater than zero. Store the //    values into two variables named 'n' and 'm'. //    Additionally, implement a while-loop to keep asking the user to enter //    the numbers again if any of the two numbers are equal or smaller than zero. // 2) If the two numbers (n, m) are equal, display the message "The //    numbers are the same". If the two numbers are different, display...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT