Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please show input and output code clearly! Thank you! Program 5- Roots (homework) CSCI 251 The two roots of a quadratic equation ax2 + bx
Please show input and output code clearly! Thank you!
Program 5- Roots (homework) CSCI 251 The two roots of a quadratic equation ax2 + bx +c can be obtained using the following formula: and r2 2a b2-4ac is called the discriminant of the quadratic equation, and its value determines the mumber of roots as follows: b2-4ac>0, tworeal roots:l and r2 b2-4ac 0, one real root: r b2-4ac 0, no real roots Write a function called roots yourLastName that takes in 3 arguments- coefficient a, coefficient b, and coefficient c, and the return value for the function expects one of three values as shown below: 0: no roots 1: one root 2: two roots b'-4ac- 0 within the function, determine the number of roots and return the corresponding number [O1, or 2). Also write how this function would be called in your main program rootsTest yourLastName.m In the main program, prompt the user for coefficients a, b, and c. Based on the number of roots, determine and output the root values, if there are any (you must use an if-statement for this You need to submit two files for this program, roots yourLastName.m and rootsTest yourLastName.m Include header comments formatted exactly as shown below but with your name, student ID, and section numbre., these comments should be the FIRST LINES in your script). Be sure to include the Honor Code statement. Your electronic submission of the program file will represent your endorsement of the Honor Code Statement. % Course: CSCI 251, Section X % Student Name:ane Doe % Student ID: 12345678 % Program 5 homework % Due Date: % In keeping with the Honor Code of UM, I have neither % given nor received assistance from anyone other than the instructor. Description: Before each significant step, provide a comment explaining the step (do not comment every line of code)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started