C++ :: Finding Area And Perimeter Of Given Coordinates

Dec 10, 2014

Below is what i have so far. My main issue is outputting the area and perimeter of the given coordinates as i need the final coordinate to connect up to the first coordinate. I've tried doing that using numberOfcorners but it says "the expression must have integral or enum type"

#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
int main() {

float ArrayX[10];
float ArrayY[10];
float numberOfcorners;

[Code] .....

View 3 Replies


ADVERTISEMENT

C++ :: Calculating Area And Perimeter

Sep 28, 2014

I am having trouble with my C++ program. My program asks the user to enter any number greater than 0 and less than 20, and if the user enters any number(s) outside the acceptable range, the output should display:

input outside of exceptable range > 0 and < 20
length: 1 width: 1 area: 1 perimeter: 1

But in my program, this output displays no matter what the user types (even if the numbers are in the acceptable range, when it should be displaying the length and width the user enters and also displaying the calculated perimeter and area whenever the user enters number(s) in the acceptable range. Here is my code:

#include <iostream>
using namespace std;

float class_rectangle_area();
float class_rectangle_perimeter();
float class_rectangle_length();
float class_rectangle_width();

[Code] .....

View 4 Replies View Related

C++ :: Calculate Area And Perimeter Of A Rectangle

Jan 28, 2013

Write a program that prompts the user to input the length of a rectangle and the width of a rectangle and then displays the rectangle's area and perimeter. The program should be broken down in 3 parts:

1. Input the length and the width (two input statements)

2. Calculate the area & perimeter (results should be saved in variables

3. print results.

Format the output so the user can easily read the results. Use the tab escape so its easy to read.
---------------------------------------------------------------
So here's what I have so far. I have been stuck for two days

#include iostream
using namespace std;
int main () {
int double length;
int width;
int area;
int perimeter;

[Code] ....

I dont want to get a zero for not turning this in...

View 14 Replies View Related

C/C++ :: Application To Calculate Area And Perimeter Of Geometric Shapes

Oct 18, 2013

How would this look like in C? Develop an application to calculate the area and perimeter of geometric shapes. First the user is asked to enter a letter representing the shape. We use C for circle, R for rectangle and S for square. After the user chooses the shape, the program prompts for the appropriate dimensions of the shape accordingly.

For instance, if the user has chosen a square, the program will ask for a side. If it's a circle, the program will ask for radius. If it's a rectangle, it will ask for length and width. Upon receiving the appropriate dimensions, the program will calculate the area and the perimeter of the requested shape and print it on the screen. And again, the code will ask for another letter. If the user enters 'Q' the program terminates.

Please Enter Shape (C: Circle, S: Square, R: Rectangle Q:quit) >S
Please enter the side of the square > 8
The area is 64 and the perimeter is 32
Please Enter Shape (C: Circle, S: Square, R: Rectangle Q:quit) >R
Please enter the width of the rectangle > 5
Please enter the length of the rectangle > 7
The area is 35 and the perimeter is 24
Please Enter Shape (C: Circle, S: Square, R: Rectangle Q:quit) >Q

View 1 Replies View Related

C++ :: Finding Coordinates In Multidimensional Array?

Mar 26, 2013

I know how to find a specific number in a multidimensional array, but I don't know how to have a specific number and find its coordinates.

View 2 Replies View Related

C++ :: Finding Pi Through Computing Area Of A Quarter Circle?

May 4, 2015

question: Finding pi through computing area of a quarter circle

my code

PHP Code:

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    int sum=0;            
    double PI,h,x;            
 
[Code] .....

View 14 Replies View Related

C++ :: How To Compute Perimeter Of A Triangle

Jun 26, 2013

I intended to compute perimeter of a triangle. The problem is the initial value for the triangle.

#include <iostream>
#include <cmath>
using namespace std;

struct Point{
double x;
double y;

[Code] ......

I expect to get 0 for triangle1, but I get some strange value...

Here is the result

Type x for point1 : 1
Type y for point1 : 1
Type x for point2 : 3
Type y for point2 : 1
Type x for point3 : 1
Type y for point3 : 3
The perimeter of the triangle1 is : 2.82843
The perimeter of the triangle2 is : 6.82843

View 2 Replies View Related

C# :: Getting Coordinates Inside Image

Feb 25, 2014

I am working on a small game and I have the following problem. I need to get the colour of a particular position in an image. Say I'm given coordinates (5,5) I need the colour of the part in the image. I think I can do the colour picking myself, but I don't know how to point at coordinates inside the image.

View 3 Replies View Related

C :: Function That Scans In Two Sets Of Coordinates

Nov 5, 2013

Night now I'm working on part of a function that scans in two sets of coordinates. Is there a way I can scan both sets of coordinates in with the same scanf?

ex. scanf("%d%d%d%d," &destroyer_1, &destroyer_2, &destroyer_3, &destroyer_4)

but that didn't work...

Code:
printf("What are the first coordinates for destroyer:
");
scanf_s("%d%d", &destroyer_1, &destroyer_2);
gameboard[destroyer_1][destroyer_2] = 'd';
printf("What are the second coordinates for destroyer:

[Code] .....

View 5 Replies View Related

C++ :: How To Find Coordinates Of Cursor Position

Feb 4, 2014

I have studied function,array,stuctures,flow of control(XI class cbse syllabus). Now I want to know how to find coordinates of cursor position in c++.

View 2 Replies View Related

C++ :: Program To Print Out X / Y Click Coordinates?

Jan 16, 2013

I use the AS/400 warehouse system, and I need to be able to automate typing one letter in several different locations to speed things up.

My thoughts are:
1. Find out how to make a program that will determine x, y coordinates of mouseclicks, and then use software to use macros to change information.
2. Build a program that will complete a single process by repeating set mouse clicks and keystrokes.

We recieve HUGE transfers from a warehouse across the country, and have to change the first character of the name of bin locations - and after a few pages it gets VERY tedious.

View 4 Replies View Related

C++ :: Mouse Input Coordinates Not Being Read

Jan 14, 2015

Essentially the problem is that when I click the mouse, the program doesn't seem to record the coordinates. So the if statements are never executed. The problem could also be with the if statements, I'm not sure.

One thing I noticed was that when the do while loop is running and the left mouse button is not pressed then X and Y of dwMousePosition are both 0. But then if I press the left mouse button then the coordinates become x = 1 and y = 0.

NOTE I'm on Windows 7, 64 bit, using Visual Studio Express 2013 for Windows Desktop

#include <iostream>
#include <windows.h>
#include <string>
#include <new>
#include <stdio.h>
using namespace std;
INPUT_RECORD ir[128];
DWORD nRead;

[Code] .....

View 1 Replies View Related

C/C++ :: Reading X / Y Coordinates In Text File

Apr 7, 2014

I need to read x,y coordinates in text file using c++. The name of file is input.txt which is,

x      y
232.1,753.7
100.5,981.6
96.2,992.9
148.7,953.2
197.2,999.3
249.9,998.6
261.7,975.9
262.4,905.8
334.9,980.8
371.6,979.4
396.7,996.3
405.1,995
565.5,766
459.4,988.5
474.4,994.6
594.6,996.8
604,987.3
612.8,877.3
664.1,992.6

#include <iostream>
#include <fstream>
using namespace std  
struct monsters_struct {
int x, y;

[Code] ....

View 1 Replies View Related

C :: Drawing A Box With Coordinates - Printing Between Certain ASCII Values

Sep 23, 2014

The assignment is:

1) Write a program that asks the user for a a single character and two XY coordinates. The two X and two Y values should all be integers between 0 and 50. The character should be a printable ASCII character with values between and including ' !' (ascii value 33) and '~' (ascii value 126).

2) Your program should then draw a rectangle made up of the user selected character where the upper left corner is at X1; Y 1 and the lower right corner is at X2; Y2. Be sure to print the appropriate number of blank lines (having spaces in the blank rows is OK) in the beginning and pad each row of your rectangle with X1 leading spaces.

The Output is supposed to be similar to this:

(X1,Y1) = (0,0) , (X2,Y2) = (4,4), the character = ^

^^^^
^^^^
^^^^
^^^^

What I am having trouble understanding is printing between certain ASCII values (ASCII has never been discussed in class).

Another thing I am having trouble with is the main part of the assignment. From what we are currently discussing is loops and the assignment is covering nested loops. My code looks similar to this:
Code:

#include <stdio.h>
int main (void) {
int X1, Y1, X2, Y2;
char cRec;
printf("Enter a character: ");
scanf("%c", &cRec);

[Code] .....

My thinking on the assignment is that you want the X1 coordinate to increase to the value of X2 (same for Y1 and Y2). Is this thinking wrong?

View 12 Replies View Related

C++ :: How To Update Coordinates To Move It Towards Center And Then Nuclei

Jan 22, 2013

I have created a sphere, inside the sphere (cell) is another smaller sphere (nuclei) located at one end and at the other end of the sphere is a structure call microtubules.The microtubules had a center point and then there are line that extend from the point to the edge of nuclei and also to the edge of the cell.

I have points (viruses) that move throughout the cell. Once the virus is on the microtubules structure ( assuming it attaches to the structure from the cell edge), it must move towards the center of the microtubules and eventually move down the line towards the nuclei.

I have already figured out how to determine if the virus is on the microtubules structure however I cant figure out how to move it down the line. I figured it out in 2D space using the quadrant system, but I cant wrap my head doing it in 3D space.Once the virus is on the microtubules how do I update the coordinates to move it towards the center and then towards the nuclei?

View 3 Replies View Related

C++ :: Display Position Of Point In Polar Coordinates

Apr 2, 2013

Write a program that prompts the user for the x and y coordinates of a point on the x-y plane, and then displays the position of that point in polar coordinates.

The program must execute via a function ‘polar’ that is called from the main function. This function accepts x & y coordinates as input value parameters, and then returns, through reference parameters, the polar coordinate position of the point (r and theta).

Could in theory be written entirely in the main function; however, to meet the problem statement the code must include a user defined function that returns polar coordinates to the main function via reference parameters.

Some programming hints:

(i)Reference parameters are declared using an ampersand after the declaration type: for example – ‘int& number’ declares a reference parameter ‘number’ of type ‘integer’.

(ii)You’ll need the cmath library for arctan and sqrt functions. The C++ syntax for the arctan function is “atan(x)”.

(iii)The C++ arctan function returns an angle in radians. For output to the screen convert the angle theta from radians to degrees.

(iv)Program should work for x, y values in all four quadrants of the x-y plane.

View 4 Replies View Related

C++ :: How To Rotate Single 3D Object By Modifying Its Coordinates

Jun 20, 2014

I would like to understand how to rotate a 3D Object around it's Center, by modifying it's Vertex Coordinates. N

The reason is that I need to keep track of the new coordinates because of my collision system, which is based on Vertex Coords.

Here is the Code for an Object

void DrawHouse(GLfloat x1, GLfloat x2, GLfloat y1, GLfloat y2,
GLfloat z1,GLfloat z2, GLfloat u1, GLfloat u2, GLfloat v1, GLfloat v2, GLuint textid) {
glBindTexture(GL_TEXTURE_2D, textid);
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(u1,v1); glVertex3f(x1,y1,z2);

[code]....

View 7 Replies View Related

Visual C++ :: Mouse Input Coordinates Not Being Read

Jan 14, 2015

When I click the mouse, the program doesn't seem to record the coordinates. So the if statements are never executed. One thing I noticed was that when the do while loop is running and the left mouse button is not pressed then X and Y of dwMousePosition are both 0. But then if I press the left mouse button then the coordinates become x = 1 and y = 0.

I am on Windows 7, 64 bit, using Visual Studio Express 2013 for Windows Desktop

Code:
#include <iostream>
#include <windows.h>
#include <string>
#include <new>
#include <stdio.h>
using namespace std;
INPUT_RECORD ir[128];

[Code] ....

View 1 Replies View Related

C++ :: How To Enter And Print X And Y Coordinates On One Line Separated By Comma

Nov 22, 2014

I'm trying to enter an 'x' and 'y' coordinate on only one line separated by a comma. But I keep getting a syntax error. Here are the lines of code I'm using. This has to be simple. What am I doing wrong with this code?

Code:
cout<< "Please enter the x and the y coordinates of the first point,"<<endl;
cout<< "use a comma to separate them. " <<endl<<endl;
cin>> "You entered: " >>x1>>",">> y1 >>"for the first point" >>endl;

View 7 Replies View Related

C :: Program To Read In A Tab Deliminated Text File Of Xyz Coordinates

Nov 14, 2013

I have been working on a program to read in a tab deliminated text file of xyz coordinates of atoms/particles and store the values in three seperate arrays. This is my code so far:

Code:

#include<stdio.h>
#include<stdlib.h>
void fileinput(FILE *ifp) {
int N, column, atom;
int c;
column = 1;

[Code]...

Supposedly this should assign the values in the text file to the cooresponding arrays but when I run the code on a simple test file all I get is:

Code:

$ ./input.o -i ./test.txt
Atom one coodinates x 0.000000, y 0.000000, and z 0.000000 Where test.txt is: Code: 1.0000 2.000 1.5
3.0000 5.000 1.4
4.0000 3.000 1.3

View 1 Replies View Related

C++ :: Parse TXT File - How To Get X And Y Coordinates Of Each Control Points From 2 Images

Jan 30, 2013

I have a text file with the following format

//MAIN OBJECT
Object = ControlNetwork
Created = 2013-01-28T12:26:17

//FIRST CONTROL POINT OBJECT
Object = ControlPoint
PointId = 1

[Code] ....

I want to get the X and Y coordinates of the each control points from 2 images.

For example, from the above file i want to retrieve such information:

-PointID=1 and point coordinates are 802,725(from image1) and 480,708 (from image2)

-PointID=2 and point coordinates are 317,130(from image1) and 128,116 (from image2)

There can be millions of points in such a text file. So what is the best way to parse these files?

View 1 Replies View Related

C++ :: How To Impose A Boundary To Stop Program Creating Coordinates

Mar 21, 2013

I am writing a program which creates a set of coordinates that when plotted will reveal a syastro crescent moon character. If you imagine plotting a crescent moon as two circles with different radius, where the overlap will create the shape. The problem I am having is how to just plot where they overlap ( ie the crescent moon part) and no the rest of the circles. How can I impose a boundary to stop the program creating coordinates I dont want. My first attempt is an if else loop.

View 1 Replies View Related

C++ :: Cartesian Class - Display Coordinates Entered By User

Apr 6, 2014

I am trying to make a program with a Cartesian class that allows the user to enter 2 coordinates and displays these coordinates. When I try to compile it, I get a message saying the x and y in x=c and y=d don't name a type. How can I fix this? Also, how would I go about inserting an assignment function that assigns the values of coord1 to coord2?

Code:
#include <iostream>
#include <istream>
#include <ostream>
using namespace std;
class Cartesian {
private:
double x;
double y;

[Code] ....

View 9 Replies View Related

C++ :: Simple Image Output - Setting RGB Values And X-Y Coordinates

May 21, 2012

I'm wanting to create an image, all I need is to be able to set RGB values and X-Y coordinates, I'm not wanting to read or manipulate images. Any easy to use library or another simple method of doing this?

View 1 Replies View Related

C++ :: List Of Latitude And Longitude Coordinates - Sorting Algorithm

Jul 4, 2012

I have a list of latitude and longitude coordinates which are supposed to trace the outline of a city. Somehow they got scrambled so that they are now out of order. I'd like to write a program to arrange them such that one could follow from one coordinate to the next and trace the perimeter. However, I've run out of ideas for algorithms. What I did so far was a simple search for the nearest coordinate, starting from the first coordinate pair in the array. This produced local regions which worked rather well, but globally there were large jumps as the algorithm ran out of nearby coordinates and was forced to jump across the map.

Is there already a developed algorithm to perform this function?

View 1 Replies View Related

C++ :: Store Coordinates As X And Y In A Vector To Find Nearest Neighbor Of Given Points

Oct 13, 2014

Lets say that i have the coordinates of a 2D space (x and y), I want to store the coordinates as x and y in a vector to find the nearest neighbor of given points like i have:

#3.57 3.18#
#84.91 27.69
#93.40 4.62
#67.87 9.71
#75.77 82.35
#74.31 69.48
#39.22 31.71
#65.55 95.02
#17.12 3.44
#70.60 43.87

Each coordinates is like x y and it shows points 1 to 10 (like 3.57 3.18 is point 1 in 2D space ). My question is that how i add all x and y coordinates in vector? I started like this;

`struct point{
int x;
int y;

[Code] ....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved