Develop a function odd_even that determines whether a number is odd or even. It must have the following features: ▪ It must take in a scalar value x Its output is a character value y. • If the value is odd, set the output equal to odd, otherwise, set it to even. • If the value of x provided by the user is not scalar, set the output equal to non-scalar. • If the value of x provided by the user is not a whole number, round it down to the nearest whole number, then proceed in determining whether it is odd or even.
Develop a function odd_even that determines whether a number is odd or even. It must have the following features: ▪ It must take in a scalar value x Its output is a character value y. • If the value is odd, set the output equal to odd, otherwise, set it to even. • If the value of x provided by the user is not scalar, set the output equal to non-scalar. • If the value of x provided by the user is not a whole number, round it down to the nearest whole number, then proceed in determining whether it is odd or even.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
How do I create this code in MATLAB?
![Develop a function odd_even that determines whether a number is odd or even. It must have the following features:
■ It must take in a scalar value x.
Its output is a character value y.
▪ If the value is odd, set the output equal to odd, otherwise, set it to even.
If the value of x provided by the user is not scalar, set the output equal to non-scalar.
■ If the value of x provided by the user is not a whole number, round it down to the nearest whole number, then proceed in determining whether it is odd or even.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc2a6209a-f883-4c3f-874f-ece416dbc83a%2Fd46a28ff-85d9-44eb-881f-1755292bd7e2%2Fktz3uz8_processed.png&w=3840&q=75)
Transcribed Image Text:Develop a function odd_even that determines whether a number is odd or even. It must have the following features:
■ It must take in a scalar value x.
Its output is a character value y.
▪ If the value is odd, set the output equal to odd, otherwise, set it to even.
If the value of x provided by the user is not scalar, set the output equal to non-scalar.
■ If the value of x provided by the user is not a whole number, round it down to the nearest whole number, then proceed in determining whether it is odd or even.
![1 function y = odd_even(x)
Code to call your function >
1 oe1 = odd_even (7)
2 oe2 odd_even (8)
C Reset](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc2a6209a-f883-4c3f-874f-ece416dbc83a%2Fd46a28ff-85d9-44eb-881f-1755292bd7e2%2Fkcy932j_processed.png&w=3840&q=75)
Transcribed Image Text:1 function y = odd_even(x)
Code to call your function >
1 oe1 = odd_even (7)
2 oe2 odd_even (8)
C Reset
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
How do I make the input rounded down to the nearest whole number?
function y = odd_even(x)
if ~isscalar(x)
y='non-scalar';
else
if ~isnumeric(x)
y=odd_even(round(x));
else
if mod(x,2)==0
y='even';
elseif mod(x,2)~=0
y='odd';
end
end
end
end
![Can the function determine if a whole number is odd?
Can the function determine if a whole number is even?
✔ Can the function determine if the value is non-scalar?
> Is the input rounded down to the nearest whole number?
Variable y has an incorrect value.
20% (20%)
20% (20%)
30% (30%)
0% (30%)](https://content.bartleby.com/qna-images/question/c2a6209a-f883-4c3f-874f-ece416dbc83a/46c9e6fe-0b80-4231-8897-557e818c3472/0gg9q7_thumbnail.png)
Transcribed Image Text:Can the function determine if a whole number is odd?
Can the function determine if a whole number is even?
✔ Can the function determine if the value is non-scalar?
> Is the input rounded down to the nearest whole number?
Variable y has an incorrect value.
20% (20%)
20% (20%)
30% (30%)
0% (30%)
Solution
Follow-up Question
How do I fix this?
![1 function y-odd_even(x)
2 if ~isscalar (x)
3
4
5
6
7
8
9
10
11
12
13
14
15 end
else
end
y='non-scalar';
if isnumeric (x)
Output
y=odd_even (round(x));
else
end
if mod (x,2)==0
y='even';
elseif mod(x, 2)!=0
y='odd';
end
Code to call your function >
1 oe1 odd_even (7)
2 oe2= odd_even (8)
File: solution.m Line: 10 Column: 28
Invalid use of operator.
C Reset
▶ Run Function ?](https://content.bartleby.com/qna-images/question/c2a6209a-f883-4c3f-874f-ece416dbc83a/8f508fc0-0fd6-473c-913e-837b681bbc92/00htjh7_thumbnail.png)
Transcribed Image Text:1 function y-odd_even(x)
2 if ~isscalar (x)
3
4
5
6
7
8
9
10
11
12
13
14
15 end
else
end
y='non-scalar';
if isnumeric (x)
Output
y=odd_even (round(x));
else
end
if mod (x,2)==0
y='even';
elseif mod(x, 2)!=0
y='odd';
end
Code to call your function >
1 oe1 odd_even (7)
2 oe2= odd_even (8)
File: solution.m Line: 10 Column: 28
Invalid use of operator.
C Reset
▶ Run Function ?
Solution
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education