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() {
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:
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...
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
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
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.
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?
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:
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.
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
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?
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?
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.
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
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;
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
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.
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;
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?
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?
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:
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;