please answer the second part first part answered.
the answer to the first part is at the bottom
bring the rest of the place
HAVE TO BE SOLVED WİTH C PROGRAMMİNG
A programming task is given in below (i.e., you are supposed to
write a single program involving all 5 tasks in below). You should
write a C program and upload your c/cpp file .
Students are allowed to use MAK104E course (powerpoint)
slights.
1) Three geometric entities (a circle, a rectangle and a triangle)
should be first randomized using rand function in line with
srand(time(NULL)).
These three geometrric entities can/should be represented using the
following C struct samples in
struct Circle
{
double x;
double y;
double r; };
struct rectangle
{
double xBottomLeft;
double yBottomLeft;
double xtopRight;
double ytopLeft; };
struct Triangle
{
double x1;
double y1;
double x2;
double y2;
double x3;
double y3; };
these three geometrric entities can/should be represented using the
following C struct samples in your program:
Write three functions for each geometric entity that randomizes the
geometric parameters (such as center X and Y coordinates and radius
for a circle) and returns these geometries (such as struct Circle,
struct Rectangle and struct Triangle). Note that floating numbers
should be randmized from 0 to 10.
2) Write three functions for each geometric entity that samples 300
points on these geometries and returns these points. Note that
these points should be represented using a linked list as in below
(in such a way that Pt1
--> Pt2 --> .... --> Pt300 --> NULL).
Use pointers to represent these linked lists. Do not forget
allocate memory (new) for pointers and deallocate (free) after
using them.
struct point
{
double x;
double y;
struct point *pnext;
};
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
struct Circle
{
double x;
double y;
double r;
};
struct Circle randomize_circle()
{
struct Circle c1;
double a=10;
/*here a=10 is the range from 0 to 10 upt0 which we
want to get the double values. as defined here.
since we cant get the direct random double values so
we find random int values in range of 0 to RAND_MAX
and then we divide it by RAND_MAX to get it in range of
[0 to 1] and then we multiply it with 10 to get the
to get it in range of [0 10]..
*/
c1.x= (double)(rand()*a)/(double)(RAND_MAX);
c1.y=(double)(rand()*a)/(double)(RAND_MAX);
c1.r=(double)(rand()*a)/(double)(RAND_MAX);
//assingn the random x ,y and return c1..
return c1;
}
//we have the rectangle as x y and x top and y top here as defined
struct rectangle
{
double xBottomLeft;
double yBottomLeft;
double xtopRight;
double ytopLeft;
};
struct rectangle randomize_rectangle()
{
struct rectangle r1;
double a=10.00;
r1.xBottomLeft=(double)(rand()*a)/(double)(RAND_MAX);
r1.yBottomLeft=(double)(rand()*a)/(double)(RAND_MAX);
r1.xtopRight=(double)(rand()*a)/(double)(RAND_MAX);
r1.ytopLeft=(double)(rand()*a)/(double)(RAND_MAX);
return r1;
}
struct Triangle
{
double x1;
double y1;
double x2;
double y2;
double x3;
double y3;
};
//we get the randomize_triangle and randomize_rectangle as defined...
struct Triangle randomize_triangle()
{
struct Triangle t1;
double a=10.00;
t1.x1=(double)(rand()*a)/(double)(RAND_MAX);
t1.y1=(double)(rand()*a)/(double)(RAND_MAX);
t1.x2=(double)(rand()*a)/(double)(RAND_MAX);
t1.y2=(double)(rand()*a)/(double)(RAND_MAX);
t1.x3=(double)(rand()*a)/(double)(RAND_MAX);
t1.y3=(double)(rand()*a)/(double)(RAND_MAX);
return t1;
}
int main(){
srand((unsigned int )time(NULL));
//we randomize_circle the teh rectangle and Triangle and get the rectangle
struct Circle c2= randomize_circle();
struct rectangle r2= randomize_rectangle();
struct Triangle t1=randomize_triangle();
return 0;
}
Here is the solution to your question. I tried my
best to solve your doubt, however, if you find it is not as good as
expected by you. Please do write your further doubts regarding this
question in the comment section, I will try to resolve your doubts
regarding the submitted solution as soon as possible.
Please give proper indentation as shown in the screenshot
If you think, the solution provided by me is helpful to you please
do an upvote.
![]() |
#include<stdio.h> struct point double getY(double x,double slope,double x1,double y1) struct Circle struct Circle randomize_circle() struct point* Circle300(struct Circle C)
struct rectangle struct rectangle randomize_rectangle() struct point* Rectangle300(struct rectangle R) x1=R.xBottomLeft; x1=R.xtopRight; x1=R.xtopRight; x1=R.xBottomLeft; return pts; struct Triangle struct Triangle randomize_triangle() struct point* Triangle300(struct Triangle T) x1=T.x1; } x1=T.x2; } //printf("%d %lf %lf\n",cnt,ntemp->x,ntemp->y); x1=T.x3; int main() struct point* tptr; tptr=ptsCircle; tptr=ptsRectangle; tptr=ptsTriangle;
|
please answer the second part first part answered. the answer to the first part is at...
Three geometric entities (a circle, a rectangle and a triangle)
should be first randomized using rand function in line with
srand(time(NULL)).
These three geometrric entities can/should be represented using
the following C struct samples in your program:
Write three functions for each geometric entity that randomizes
the geometric parameters (such as center X and Y coordinates and
radius for a circle) and returns these geometries (such as struct
Circle, struct Rectangle and struct Triangle). Note that floating
numbers should be...
Create a UML diagram with 3 lines per class/interface including all constructors. public class Point { public double X, Y; public Point() { this(0, 0); } public Point(double newX, double newY) { X = newX; Y = newY; } public static double distance(Point A, Point B) { return Math.sqrt(Math.pow(A.X-B.X, 2) + Math.pow(A.Y-B.Y, 2)); } } public interface Polygon { public int getNumberOfSides(); public double getPerimeter(); public double getArea(); } public abstract class Simple_polygon implements Polygon{ public Point...
1. In IntelliJ create a new project called F1_2 2. In the Project window create a new Java package called F1_2. This can be done by right clicking on src and going to New ! Package. 3. In package lab1 2 create a class called Rectangle. This can be done by right clicking on the package and going to New ! Java Class 4. At the beginning of Rectangle.java add the line package lab1 2; 5. In Rectangle.java create a...
GUI in java: Run the below code before doing the actionlistener: import java.awt.*; import javax.swing.*; public class DrawingFrame extends JFrame { JButton loadButton, saveButton, drawButton; JComboBox colorList, shapesList; JTextField parametersTextField; DrawingFrame() { super("Drawing Application"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true); toolbar.add(loadButton=new JButton("Load")); toolbar.add(saveButton=new JButton("Save")); toolbar.addSeparator(); toolbar.add(drawButton=new JButton("Draw")); toolbar.addSeparator(); toolbar.addSeparator(); toolbar.add(new...
JAVA PROGRAM USING ECLIPSE. THE FIRST IMAGE IS THE
INSTRUCTIONS, THE SECOND IS THE OUTPUT TEST CASES(WHAT IM TRYING TO
PRODUCE) BELOW THOSE IMAGES ARE THE .JAVA FILES THAT I HAVE
CREATED. THESE ARE GeometircObject.Java,Point.java, and
Tester.Java. I just need help making the Rectangle.java and
Rectangle2D.java classes.
GeometricObject.Java:
public abstract class GeometricObject {
private String color = "white"; // shape color
private boolean filled; // fill status
protected GeometricObject() { // POST: default shape is unfilled blue
this.color = "blue";...
Please help with C
Thanks
Declare a structure to represent a circle. Each circle stores information about the center and the radius. Center is represented with x and y coordinates. Both center and radius uses doubles. Allocate an array of 50 circle pointers and dynamically allocate memory to store a circle pointed by cash array eatery. Randomly generate circles using the following function. double rand_float (double a.double b) {return ((double)rand()/RAND_MAX)=(b-a)+a:} We want all the circles to fit an area of...
Using python
Here is the code
import turtle
def draw_triangle(vertex, length, k):
'''
Draw a triangle at depth k given the bottom vertex.
vertex: a tuple (x,y) that gives the coordinates of the bottom
vertex.
When k=0, vertex is the left bottom vertex for the outside
triangle.
length: the length of the original outside triangle (the
biggest one).
k: the depth of the input triangle.
As k increases by 1, the triangles shrink to a smaller
size.
When k=0, the...
I
need help with C, please don't copy other answers!!
Thanks
Declare a structure to represent a circle. Each circle stores information about the center and the radius. Center is represents with x and y coordinates. Both center and radius uses doubles. Allocate an array of 502 circle pointers and dynamically allocated memory to store a circle pointed by each array entry. Randomly generate circles using the following function. double rand_ float (double a, double b) {return ((double) rand()/RAND_MAX) *...
MATLAB only please
I am trying to get my getdatafuntion to work. I am also trying
to get all my x's, y's, and v's to popup in the command window so I
can put in any value and it will find the value for me using
the equation I put in.
function project_9_sjl()
% PROJECT_9_SJL project_9_sjl() is the driver function for the
program.
%
% Name: Scott Lawrence
% Date: 3/27/2019
% Class: CMPSC 200
% Description: Determine the optimal...
Please use C++ and Please do all file separate separately. And also I need output too. thanks. Please do it complete work. ShapeNodePoly.cpp Avaliable from: Wednesday, July 27, 2016, 10:20 AM Requested files: Point.h, Point.cpp, Shape.h, Shape.cpp, Polygon.h, Polygon.cpp, Ellipse.h, Ellipse.cpp, ShapeNodePoly.cpp, ShapeNodePoly_test.cpp (Download) Type of work: Individual work In this assignment, you will create a class that can behave as any of the shapes listed below. You will use object inheritance to enable all shapes to be managed using...