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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/zwang/circ_nathan.cpp
//	 CS 207 Assignment 2
//       
//	 Filename: 	circ.cpp
// 	 
//	 Author: 	Nathan Lutz
//
//	 Instructor: 	Dr. Wang
//	 Due: 
// 	 Compile:	g++ circ.cpp -o circ.out
//	 Run:		./circ.out
//	 Goal: To display a circle of user defined length, composed by a character also specified by the user

#include <iostream>
#include <cmath>

using namespace std;

bool oncircle(int,int,int);

int main()

{
	 int length,i,j;
	 char letter;
	 string answer;
	
	 do
	 {
	         cout<<"Please enter the diameter of the circle you want displayed."<<endl;
	 	 cin>>length;
		 if(length <0 || length >9999)
		 {
		 cout<<"This is not a valid entry."<<endl;
		 return 0;
		 }
	         cout<<"Please enter the character you want the circle to be composed of."<<endl;
	 	 cin>>letter;

	 	 for(i=0;i<length;i++)
	 	 {
		 	 for(j=0; j<length; j++)
		 	 {
	 	 	 	if(oncircle(i,j,length))
	 	 		cout<<letter;
				else
		 		cout<<"  ";   			
		 	 }
		 	 cout<<endl;
		 }
		 cout<<"\nDo you wish to make another?"<<endl;
		 cin>>answer;

	 } while(answer!="no" && answer!="No");
	 cout<<"Thank you."<<endl;
	 return 0;
}

	bool oncircle(int i, int j, int length)
	{
		 double radius = (length-1)/2;
		 double distance = sqrt((radius-i)*(radius-i) + (radius-j)*(radius-j));
		 double difference = distance - radius;

		 if(difference <= .25 && difference >= -.25)
		        return true;
		 return false;
	}
	

Stv3n404 - 2023