Welcome to Gaia! ::

zOMG! Chatterbox

Back to Guilds

Do you like zOMG? Do you like to chat? Then click here. It will be the best decision you make. Ever. EVER!!11oneoneone 

Tags: zOMG, Chatterbox, Landshark, Marshall, Animated 

Reply Recycle Bin
bin bin ty ty

Quick Reply

Enter both words below, separated by a space:

Can't read the text? Click here

Submit

Mickeymoot

PostPosted: Tue Sep 18, 2012 12:59 pm


It looks like the only time I post here is if I want something lol. I do check regularly though, just never post emotion_yatta

C++ btw.

So basically, I ask the user for the center points and radii of three circles. Then ask for a quary point. I need to write a program as to see whether the quary point is in circle A, B, C, a combination of the three, or in no circle whatsoever. I have an .exe file that I'm comparing my solutions to, but I don't seem to output the right answer. Could anyone help me? emotion_facepalm


/*
Synopsis:
This program reads in three circles and a query point
and reports which circles contain the query point.
*/

#include
#include
using namespace std;

int main()
{
// Variable declarations

double x1; // x coordinate of circle A
double y1; // y coordinate of circle A
double rA; // radius of circle A
double x2; // x coordinate of circle B
double y2; // y coordinate of circle B
double rB; // radius of circle B
double x3; // x coordinate of circle C
double y3; // y coordinate of circle C
double rC; // radius of circle C
double Q1; // x coordinate of query point
double Q2; // y coordinate of query point
double dxA(Q1-x1); // dx for circle A
double dyA(Q2-y1); // dy for circle A
double dxB(Q1-x2); // dx for circle B
double dyB(Q2-y2); // dy for circle B
double dxC(Q1-x3); // dx for circle C
double dyC(Q2-y3); // dy for circle C

// Prompt and read in circle A center coordinates

cout << "Enter x and y coordinates of circle A (2 values): ";
cin >> x1 >> y1;

// Prompt and read in circle A radius

cout << "Enter radius of circle A: ";
cin >> rA;

// Prompt and read in circle B center coordinates

cout << "Enter x and y coordinates of circle B (2 values): ";
cin >> x2 >> y2;

// Prompt and read in circle B radius

cout << "Enter radius of circle B: ";
cin >> rB;

// Prompt and read in circle C center coordinates

cout << "Enter x and y coordinates of circle C (2 values): ";
cin >> x3 >> y3;

// Prompt and read in circle C radius

cout << "Enter radius of circle C: ";
cin >> rC;

// Prompt and read in query point

cout << "Enter x and y coordinates of query point (2 values): ";
cin >> Q1 >> Q2;

// Determine location of query point relative to the circles

if (sqrt(dxA*dxA + dyA*dyA) <= rA)
{
if (sqrt(dxB*dxB + dyB*dyB) <= rB)
{
if (sqrt(dxC*dxC + dyC*dyC) <= rC)
{ cout << "Circles A, B and C contain point (" << Q1 << "," << Q2 << ")." << endl; }
else
{ cout << "Circles A and B contain point (" << Q1 << "," << Q2 << ")." << endl; }
}
else
{
if (sqrt(dxC*dxC + dyC*dyC) <= rC)
{ cout << "Circles A and C contain point (" << Q1 << "," << Q2 << ")." << endl; }
else
{ cout << "Circles A contains point (" << Q1 << "," << Q2 << ")." << endl; }
}
}
else if (sqrt(dxB*dxB + dyB*dyB) <= rB)
{
if (sqrt(dxC*dxC + dyC*dyC) <= rC)
{ cout << "Circles B and C contain point (" << Q1 << "," << Q2 << ")." << endl; }
else
{ cout << "Circle B contains point (" << Q1 << "," << Q2 << ")." << endl; }
}
else
{
if (sqrt(dxC*dxC + dyC*dyC) <= rC)
{ cout << "Circle C contains point (" << Q1 << "," << Q2 << ")." << endl; }
else
{ cout << "No circle contains point (" << Q1 << "," << Q2 << ")." << endl; }
}
return 0;
}
PostPosted: Tue Sep 18, 2012 1:08 pm


What you need is someone who understands programming, I wish you luck in your search

Cannibal Horsey

Man-Hungry Lovergirl

12,750 Points
  • Object of Affection 150
  • Love Machine 150
  • Elocutionist 200

Divine_Malevolence

Blessed Tactician

11,250 Points
  • Beta Contributor 0
  • Beta Critic 0
  • Contributor 150
PostPosted: Tue Sep 18, 2012 1:44 pm


I would make a circle object.
Give the circle private ints cenX, cenY, and rad.
public boolean inside(double coordX, coord Y)
{
cenX=cenX-coordX;
cenY=cenY-coordY;
if(Math.sqrt((cenX*cenX)+(cenY*cenY)return true;
return false;
}





But that's Java.
I'm not sure exactly how much C++ has.
And making an object would allow for future changes. Like if you wanted to check for an oval. Or a square. Or any shape that can be graphed.



Also, make a boolean array. Your if/else statements at the end are really annoying to look at. The end message could be:

System.out.print("The query point was found")
if(!circles[0](A boolean that would be changed to true if any circles found it))
System.out.print(" in no circles")
else
{
System.out.print(" in the following circles:")
for(int i=1; iif(circles[i])
System.out.print((char)(i+(whatever value needed to make a lowercase a))",")
}
System.out.print(".")





Of course, again, I'm not sure what C++ can do.
PostPosted: Tue Sep 18, 2012 2:07 pm


See, I would love to make a function for this, but I've been told to do it the "obnoxiously long stupid way" to get full credit on the assignment. I'm not sure if I'm allowed to use the "return true/false" which is why I'm using if/else/else if.

And yes, it's messy. My indents didn't go through, I apologize. rdsjyfg;hghlkfdsgjkl;

Mickeymoot

Reply
Recycle Bin

 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum