Lab 6 Use the lab5.cpp as a started file. Modify the program is it generates 1000 points with a random x and y being values between 0 and 10000 and random c being either an 'A', 'B' or 'C'. Your program should ask for a point from the user and your program should assign a c value to that point based on the 5 closest points to it. The c value will be equal the to the most common c value of the 5 closest points.( in the case of a tie it should become an A if A and B tie, a B if B and C tie and an A is A and C tie). It should print out the 5 nearest points and the c value of the input point. Enter X and Y00 (14,9) is class A and the distant is 16.6433 (9,52) is class B and the distant is 52.7731 (17,52) is class A and the distant is 54.7083 (57,4) is class B and the distant is 57.1402 (36,46) is class B and the distant is 58.4123 (0,0) is class B
Lab 6 Use the lab5.cpp as a started file. Modify the program is it generates 1000 points with a random x and y being values between 0 and 10000 and random c being either an 'A', 'B' or 'C'. Your program should ask for a point from the user and your program should assign a c value to that point based on the 5 closest points to it. The c value will be equal the to the most common c value of the 5 closest points.( in the case of a tie it should become an A if A and B tie, a B if B and C tie and an A is A and C tie). It should print out the 5 nearest points and the c value of the input point. Enter X and Y00 (14,9) is class A and the distant is 16.6433 (9,52) is class B and the distant is 52.7731 (17,52) is class A and the distant is 54.7083 (57,4) is class B and the distant is 57.1402 (36,46) is class B and the distant is 58.4123 (0,0) is class B
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
Related questions
Question
#include <iostream>
#include <ctime>
#include <cmath>
const int MAX = 1000;
const char CLASS[] = {'A','B','C'};
struct Points{
int x,y;
char c;
double dist(Points q){
return sqrt(pow(x-q.x,2)+pow(y-q.y,2));
}
};
int main(){
return 0;
}
int main(){
srand(time(0));
}
![Lab 6
Use the lab5.cpp as a started file. Modify the program is it
generates 1000 points with a random x and y being values
between 0 and 10000 and random c being either an 'A', 'B' or
'C'. Your program should ask for a point from the user and your
program should assign a c value to that point based on the 5
closest points to it. The c value will be equal the to the most
common c value of the 5 closest points.( in the case of a tie it
should become an A if A and B tie, a B if B and C tie and an A is
A and C tie). It should print out the 5 nearest points and the c
value of the input point.
Enter X and Y00
(14,9) is class A and the distant is 16.6433
(9,52) is class B and the distant is 52.7731
(17,52) is class A and the distant is 54.7083
(57,4) is class B and the distant is 57.1402
(36,46) is class B and the distant is 58.4123
(0,0) is class B](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff32ec17f-060a-4802-86d8-ab2035a77536%2F6bbb273e-bea9-4704-8ec8-237eb0f06713%2Fp1uepft_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Lab 6
Use the lab5.cpp as a started file. Modify the program is it
generates 1000 points with a random x and y being values
between 0 and 10000 and random c being either an 'A', 'B' or
'C'. Your program should ask for a point from the user and your
program should assign a c value to that point based on the 5
closest points to it. The c value will be equal the to the most
common c value of the 5 closest points.( in the case of a tie it
should become an A if A and B tie, a B if B and C tie and an A is
A and C tie). It should print out the 5 nearest points and the c
value of the input point.
Enter X and Y00
(14,9) is class A and the distant is 16.6433
(9,52) is class B and the distant is 52.7731
(17,52) is class A and the distant is 54.7083
(57,4) is class B and the distant is 57.1402
(36,46) is class B and the distant is 58.4123
(0,0) is class B
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![Systems Architecture](https://www.bartleby.com/isbn_cover_images/9781305080195/9781305080195_smallCoverImage.gif)
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning