Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HOMEWORK 6 A Review of C++ 1. Write the code (IN C++!!!) to have the user enter a number, then print out BINGO if the

HOMEWORK 6 A Review of C++ 1. Write the code (IN C++!!!) to have the user enter a number, then print out BINGO if the number is negative AND a multiple of 8, dud . . . otherwise. Prompt the user if he/she wishes to enter another number. (25 points) 2. Write the code to have the user enter 10 doubles into an array, then compute the average of these 10 values. USE SYMBOLIC CONSTANTS!!! Format the average to display 2 decimal places. (25 points) 3. Write the code to compute the area of a circle of radius r. You MUST use a function that returns this area; also, you must use a symbolic constant for PI. Finally, you must display the area with two decimal places with appropriate units. (25 points) 4. Given the following code: #include #include using namespace std; struct Location { double xc; double yc; double zc; }; struct Point { int idNum; double distance0; // distance from ORIGIN double distance1; // distance from KEYPOINT struct Location coords; }; const int NUMPOINTS = 3; const Location ORIGIN = {0.0, 0.0, 0.0}; const Location KEYPOINT = {11.0, 3.0, 4.9}; void getData(struct Point &P, int i); float getDistance(struct Location P1, struct Location P2); int main(void) { int i = 0; struct Point myPoints[NUMPOINTS];

H06_v01b.docx Page 2 (of 2) April 26, 2021 / March 12, 2022 for(i=0; i> P.coords.xc; cout << "\tEnter x-coordinate: "; cin >> P.coords.yc; cout << "\tEnter x-coordinate: "; cin >> P.coords.zc; P.distance0 = getDistance(P.coords,ORIGIN); P.distance1 = getDistance(P.coords,KEYPOINT); } float getDistance(struct Location P1, struct Location P2) { float temp1 = pow((P1.xc-P2.xc),2); float temp2 = pow((P1.yc-P2.yc),2); float temp3 = pow((P1.zc-P2.zc),2); return(sqrt(temp1+temp2+temp3)); } Now, assume that the following data is entered at the input prompts for the coordinates of our points: <3,4,5>; <5,5,5>; and <6,7,8>. a. What value is stored in myPoints[2].idNum? (5 points) b. What value is stored in myPoints[0].coords.yc? (5 points) c. Assume that the following code is added at the end of main: for (i=0; i

What is the output of this code? (15 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions