{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# COS120_hw3 - Page 1 of 3 COS120 Software Development Using...

This preview shows pages 1–3. Sign up to view the full content.

26da7250e69ea9b4563991b8d71f9d691aec1f27.doc Page 1 of 3 COS120 Software Development Using C++ Student: Homework Nmr 03 (Decisions) Tasks: Write a program to compute roots (solutions) of a linear equation bx + c = 0 and to compute roots (solutions) of a quadratic equation ax2 + bx + c = 0 Write a program to test user defined function qualityPoints that checks a student’s average and returns 4 if a student’s average is 90-100, 3 if the average is 80-89, 2 if the average is 70-79, 1 if the average is 60-69, and 0 if the average is below 60. Task 1 #include <iostream> #include <math.h> #include <cctype> using namespace std; int main(void) { float a, b, c, x1, x2, x3, x4; //we declare the variables as float because we //are dealing with square roots cout << "Enter the coefficients a , b , c :\n"; cin >> a >> b >> c; //are all the coefficients 0? if so both roots are 0 if(a == 0 && b == 0 && c == 0){ x1 = 0; x2 = 0; cout << "The roots are:" "\n" << "x1 = " << x1 << " , " << "x2 = " << x2 << "\n"; } //is c the only non-zero number? else if(a == 0 && b == 0 && c != 0){ cout << "There are no roots" "\n" << "c = " << c << "\n"; } else if(a == 0 && b != 0 && c !=0){ cout << "x = " << -c/b << "\n";

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
26da7250e69ea9b4563991b8d71f9d691aec1f27.doc Page 2 of 3 }
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern