COP 2334: C++ Programming Programming Project # 1 Project Goals: To write a C++ program that:  Gets us started programming in C++  Utilizes the selection (if, if..else) construct. Program...

Write a C++ program that will display to the user the number of real roots of the equation for different user-provided values of a, b, and c, and then computes and displays the real roots (if there are no real roots, the program should say so).


COP 2334: C++ Programming Programming Project # 1 Project Goals: To write a C++ program that:  Gets us started programming in C++  Utilizes the selection (if, if..else) construct. Program Description: Recall that the quadratic formula, which is used to determine the roots of the general quadratic equation, is this: ? = −? ± √?? − ??? ?? Write a C++ program that will display to the user the number of real roots of the equation for different user-provided values of a, b, and c, and then computes and displays the real roots (if there are no real roots, the program should say so). 1. Prompt the user for three values: a, b, and c. The format of the prompt is as follows: Please enter an integer value for a: -> Please enter an integer value for b: -> Please enter an integer value for c: -> Remember that the user will press after inputting their values, which will drop the cursor to the next line! 2. Compute the value of the discriminant and use the result to determine how many roots exist and display that information to the user. NOTE: the discriminant of the quadratic equation is the value of the arithmetic expression under the radical ?? − ??? Also, the value of the discriminant determines the number of real roots as follows:  Discriminant is positive  Two real roots  Discriminant is zero  One real root  Discriminant is negative  No real roots You must use the arithmetic operator for multiplication and the assignment operator to store the computed value into a variable. Once you have computed this value, display the number of roots you will compute to the user. 3. Compute and display the real roots of the equation. If no real roots exist, display a message that says so. An important note: You may be wondering: How are we going to compute a square root? We will have to get ahead of ourselves a little and use what is called a “function” from the library. We will learn about functions in chapter 3, but for now, know that we can use the sqrt() function from the math library to compute the square root for us! At the top of your program, include the math library: #include Later in your program you can do this: double discriminant = ... (1) double root = sqrt(discriminant); (2) If discriminant were assigned 25 when its value was computed at (1), then root will have the value 5 after (2) executes! Specifications: 1. The program must display clear, explicit prompts for the user. 2. The program must display clear, understandable statements for all output. Submission: 1. Compile and run your program one last time before submitting it. Your program must run in the version of C++ you get through ArgoApps. 2. The name of your program file should be: lastname_firstname_project#.cpp, where ‘#’ is the number of the project (in this case, ‘1’). For example, if your name is Ricky Landry and you are submitting project 1, your source code file should be named landry_ricky_project1.cpp 3. Login to UWF's eLearning system at http://elearning.uwf.edu/. Select our course. 4. Select the Assignment and click on the “Submit Assignment” button on the top. 5. Upload your file and check make sure it finished. 6. Be sure to review the university policy on academic dishonesty. This is an individual project and you should not work with anyone else in completing it. Do not hesitate to ask me questions if you need help! Important Notes: Projects will be graded on whether students correctly solve the problem, and whether they adhere to good programming practices including use of comments as specified in the materials, using meaningful variable names, and proper indentations. Projects must be submitted by the time specified as the due date. Projects submitted after that time will get a grade of zero. Please review UWF's academic conduct policy. Note that viewing another student's solution, whether in whole or in part, is considered academic misconduct. Also note that submitting code obtained through the Internet or other sources, whether in whole or in part, is considered academic misconduct. All programs submitted will be reviewed for evidence of academic misconduct, and all violations will be handled accordingly. proj1_addendum COP 2334 Programming Project #1 – Addendum Add the following in the Specifications section: 3. The prompts for the user must be exactly as shown in paragraph 1 of the Program Description section. 4. The output must be exactly as shown below, where and are the values of the roots. a. For two real roots, output the smaller root first and the larger second in any order: Two real roots: (1) Example: Two real roots: -3.73205 -0.267949 b. For one real root: One real root: (1) Example: One real root: -1 c. No real roots: No real roots 5. You need not format the values of the roots. The default format is sufficient. 6. You need not validate the user input. You may assume that the user will enter an integer at each prompt, and the input for a will not be 0. 7. Sample runs (user input in blue, the root values may or may not be correct): Please enter an integer value for a: -> 1 Please enter an integer value for b: -> 4 Please enter an integer value for c: -> 1 Two real roots: -3.73205 -0.267949 Please enter an integer value for a: -> 1 Please enter an integer value for b: -> 2 Please enter an integer value for c: -> 1 One real root: -1 Please enter an integer value for a: -> 1 Please enter an integer value for b: -> 1 Please enter an integer value for c: -> 1 No real roots.
Sep 14, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here