Write two functions, one that displays a circle and one that displays a rectangle. Use these functions to write a complete C program from the following outline:
int main()
{
/* Draw circle */
/* Draw rectangle */
}
Do NOT use #include<graphics.h>
/* * C Program to print cirlce and rectangle */ #include <stdio.h> #include <math.h> void printCircle(int length, int width) { int y, x, radius = 10; for (y = width; y >= -width; y -= 2) { for (x = -length; x <= length; x++) { if ((int)sqrt(pow(x,2)+pow(y,2)) == 10) printf("*"); else printf(" "); } printf("\n"); } } void printRectangle(int length, int width) { int i, j; for (i = 0; i < length; i++) { for (j = 0; j < width; j++) { if(i == 0 || i == length-1 || j == 0 || j == width-1) printf("* "); else printf(" "); } printf("\n"); } } int main() { int r=10, length, width; length = r*1.5, width = r; printCircle(length, width); printf("\n\n"); length = 20, width = 10; printRectangle(length, width); return 0; }
Write two functions, one that displays a circle and one that displays a rectangle. Use these...
in C++ use Inheritance for the following Shape Circle Sphere Cylinder Rectangle Square Cube You must define one class for each shape. And, use public inheritance when deriving from base classes. Circle int r; void area(); void perimeter(); void volume(); //No volume for circle Sphere int r; void area();//Sphere surface area= 4 × pi × radius2 void perimeter(); //No perimeter for Sphere void volume();//Sphere volume= 4/3 × pi × radius2 Cylinder int r, height; void area();// Cylinder surface area=perimeter of...
Q2 Write a JavaFX program that displays a rectangle with upper-left corner point at (40, 40), width 40, and height 60. Display a circle with radius 30 centered at the mouse point when the mouse is clicked. Display a text to indicate whether the circle contains, intersects, or is outside of the rectangle, as shown in Figure 3. Create the GUI programmatically. DO not use FXML.
Given the incomplete program below, write two functions, one called integer and another called decimal. You can use following incomplete program. Your assignment is to supply the necessary missing code: #include #include using namespace std; int integer (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER (A DOUBLE) //WRITE HERE THE CODE TO EXTRACT THE INTEGER AND RETURN IT } double decimal (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER //WRITE HERE THE CODE TO EXTRACT THE DECIMAL PORTION,...
please use c++ Write a program that contains a class Rectangle with two private double precision members iLength and iWidth, public set and get member functions for these two members, a two argument constructor that sets the length and width to any two user specified values and a void function area() that computes the area and then prints this value by inserting it into the cout output stream. Write a main function that ereates a Rectangle with a length of...
Write one complete C program that asks the user for a floating point number and displays the absolute value of the number with two decimals of accuracy. You are not allowed to use the abs or fabs functions.
Geometric calclator use python to do this program. Write a program that displays the following menu: 1. Calculate the area of circle 2. calculate the area of rectangle 3. calculate the area of triangle 4. Quit Enter your choice (1-4). if the user enters 1, your program should ask for the radius of the circle and then display its area. Use the formula to calculate the circle's area: Area = pi*r^2 Use 3.14149 for Pi and the radius of the...
.Your solution must include header, implementation file, and test files .In C++ write a code to Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for Height, Width and center point, while a square and circle might have only a center point and an edge length or radius. In a well-designed system, these would be derived from a common class, Figure. You are to...
(PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...
Using the program segment below, write two short functions to complete the program. Use the test cases to ensure the program works properly. Prototypes: void int2bin(int, int[8]); The first function will convert an integer that is between 0 - 255 to its binary representation. You are to store the binary number in the array passed to the function. void printBinary(int[8]); The second function will print the binary number stored in the array passed to the function. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Test 1: 13...
PP.14 PP 3.13 Write a JavaFX application that draws a circle centered at poinit (200, 200) with a random radius in the range 50 to 150. Each time the program is run it will draw a different circle. PP 3.14 Write a JavaFX application that displays your name rotated at a random angle (0 to 360). Each time the program is run it will draw your name at a different angle. a random color created using the rgb method of...