Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.138.126.124
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/vnlaughlin/../kebuck/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/vnlaughlin/../kebuck/hw4.cpp
//	CS112		Computer Programming Assignment 4(i)
//
//	File: hw4.cpp
//	Author: Katie Buck
//	Instructor: Dr. Wang
//
//	Compile: g++ hw4.cpp
//	Run: ./a.out
//
//	Goal: The goal of this program is to use loops to solve the 
//	quadratic equation to one decimal place.

#include <iostream>
#include <iomanip>
#include <cmath>
         
using namespace std;
                
int main()
{
        cout << fixed << showpoint << setprecision(1);
        char letter;
	float x, y;
	int a, b, c;
                        
        cout << "Do you want to run? (y=yes, q=quit): ";
        cin >> letter;


	while(letter != 'q')
	{

	cout << "Input the three integers a, b, and 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 the program again? (y=yes, q=quit): ";
        cin >> letter;

	}        
        return 0;
}

Stv3n404 - 2023