Explanation of Solution
The corrected program is given below with errors and corrections explained in the in-lined comments:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//declare double type pointer variables
double *length;
double *width;
//set the output format
cout << fixed << showpoint << setprecision(2);
//allocate memory to be referred to by length
length = new double;
//the statement is incorrect as length is pointer
//variable and not a double variable
///length = 6.5;
//so the correct code is
*length = 6.5;
//statement is incorrect as & is an address of operator
/// &width = 3.0;
//so the correct set of statements are shown below
//where first memory is allocated and then the value
//is assigned
width = new double;
*width = 3...
Trending nowThis is a popular solution!
Chapter 12 Solutions
C++ Programming: From Problem Analysis to Program Design
- Assuming that you have the functions "drawPolygon(int[] x, int[] y, int n)" for drawing polygon, "drawRectangle(int x, int y, int width, int height)" for drawing rectangle and "drawCircle(int xc, intyc, int radius)" for drawing circle; draw the given shape. Where: R(300,250), T1(325,275), T2(475,275), T3(400,400), Pı(285.250), P2(225.275), P3(200,450), P4(285, 300), Q1(515,250), Q2(575,275), Q3(600,450), Q4(515,300) C6: (300,75), R=50 C7: (500,75), R=50 C1: (400,150), R=100 С4: (350,150), R-10 C5: (450,150), R=10 C2: (400,195), R=50 C3: (400,175), R=30 C8: (400,225), R=15 P1 R P2, T2 P4 Q2 Q4 T3 Pa 200arrow_forward(Needs to write a java program. The imput file that the code will be tested on will be really large, but a code that can work on the provided sample in the picture should work just fine) An image is an array, or a matrix, of pixels (picture elements) arranged in columns and rows. RGB is one of the models used in color pixels. In a color image, each RGB pixel is an integer number which contains the mixture of red, green and blue colors. In this assignment, you will be provided with an image data file, image.dat. The first line in data file contains the height (rows) and width (columns) of the image. The following lines gives the red, green and blue color integer values for each pixel. The following sample.dat is given as an example: (The given example can be seen on the picture down) According to this input file, the image has 4 rows and 2 columns. The pixel at [0][0] has red value 117, green value 117 and blue value 245. Write a Java program that reads from the given input file and…arrow_forwardAnalyze the following code. int x = 13B while (0 < x) && (x < 100) System.out .printin(x++); The numbers 2 to 100 are displayed. The code does not compile because the loop body is not in the braces. O The loop runs forever. The code does not compile because (0 < x) && (x < 100) is not enclosed in a pair of parentheses. The numbers 1 to 99 are displayed.arrow_forward
- Nonearrow_forwardHi, but the answer is incomplete(please see below): f. Create a new StringBuilder Object using no-arg constructor. g. Using for loop append the array elements one by one to the StringBuilder (one per loop iteration) h. Record a run-time it took to append all integers to the StringBuilder (record run-time of 2.g.)) i. Repeat the testing with 500 and 5,000 elements by again creating new integer arrays with 500 and 5000 sizes respectively. j. Record and display the run-time it took to append all integers to the String and StringBuilder respectively. k. Submit the screenshot of results and a small summary in the form of a table below :arrow_forwarda. Create a 1D array of integers to store 50 integers. b. Store values from 0 to 49 into the array you just created. c. Create a new String Object using no-arg constructor. d. Using for loop append the array elements one by one to the String (one per loop iteration) e. Record and display a run-time it took to append all integers to the String (record run-time of 1.d.)). E.g. "It took nanoseconds to append 50 integers to the Stringarrow_forward
- Please complie it.Make the screenshot of program and ouput both.Attach both screenshots please.arrow_forwardProblem Descriptions: In this problem, your task is to write a program to find whether a user-entered 2-D point (P) lies (i) (ii) (iii) The circles are specified using their center coordinates and radii. See the illustrations below showing all three cases you need to consider: within both of the two given circles, within only one of those circles, or outside both circles (treat a point ON a circle as being inside the circle). Pis outside both circles Pis inside ONLY one circle Sample Outputs: Sample output #1 POINT MEMBERSHIP WITHIN TWO CIRCLES Circle 1: center at ( 6, -5 ) and radius: 3 Circle 2: center at ( 12, -7 ) and radius: 5 Please enter the x-coordinate of the test point: 8 -5 Please enter the y-coordinate of the test point: Point lies within both circles. Sample output #2 POINT MEMBERSHIP WITHIN TWO CIRCLES Circle 1: center at ( 6 , -5 ) and radius: 3 Circle 2: center at ( 12 , -7 ) and radius: 5 Please enter the x-coordinate of the test point: 12 Please enter the y-coordinate…arrow_forwardEx1: If A=the odd numbers between (1,20), B= the even numbers between (2,20) find (1)A+B, (2)A.B, (3) A', B' ,(4)A'.B' ,(5)A*B, (6)A*B' (7) A'/B' ,(8)A'./B' ,(9)A/B (10)A./Barrow_forward
- "Scan Line Conversion". All questions require you to extend one of the line drawing algorithm to handle difference combination of the two end points. For the programming question, the final result function should be assigned to a variable named myAnswer. The variable myAnswer need to be accessed by the system, it should NOT preceded by let nor var.The output need to plot such a line. 2.[JavaScript] Extend the Octantal DDA algorithm so that it can handle any combination of x1, y1, x2, y2. Your function must based on the original Octantal DDA algorithm and the resulting function should be assigned to the myAnswer variable.arrow_forwardDO NOT COPY FROM OTHER WEBSITES COrrect and detailed answer will be Upvoted else downvoted. Thank you!arrow_forwardQ2. You are the class representative and your class advisor always requests your help to prepare the result analysis after each internal assessment. One of the tasks that your class advisor has assigned to you is to find whether a student has scored a 0 in a course.Given the scores of the 'n' students in the class, write a python program to find whether how many students have scored a zero in a course. Use arrays to store the marks of the students and assume that the maximum number of students in a class is 50.oarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,