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
icon
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
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning