Question: Write a program that will implement a point struct that is store three ints (x,y,z) and a char (cl). The struct should also have two

Write a program that will implement a point struct that is store three ints (x,y,z) and a char (cl). The struct should also have two functions one the gets the distances between two points

((1 2 ) 2 + (1 2 ) 2 + (1 2 ) 2 ) and one that returns a string of in the format (x,y,z) is class cl. The classes will be A , B, C or D. Your program should read in a file that is a list of points ( one point per line) and stores them in a vector of points. Your program should ask for a point from the user and your program should assign a class value to that point based on the k closest points to it. The class value will be equal the to the most common class value of the k closest points.( in the case of a tie it should become an A > B > C >D). It should print out the K nearest points and the class value of the input point and need it to the chart. Then ask the user if they wish to enter another point. Remember to break your code into functions.

Enter X and Y and Z 1000 500 3 What is the value for k

4

(732,298,529) is class A

(689,249,487) is class A

(662,286,489) is class A

(815,274,565) is class A

point (1000,500,3) is class A

Would you like to try another point( type y for yes)

y

Enter X and Y and Z 0 0 0

What is the value for k

8

(66,-67,1) is class C

(85,-67,42) is class C

(-67,-98,-64) is class B

(-37,-34,134) is class B

(-71,39,131) is class D

(-88,-122,48) is class B

(99,75,107) is class A

(-169,19,-41) is class D point (0,0,0) is class B

Would you like to try another point( type y for yes)

Y

Enter X and Y and Z -203 -40 800

What is the value for k

3

(18,320,356) is class A

(192,48,316) is class A

(-87,208,223) is class D

point (-203,-40,800) is class A

Would you like to try another point( type y for yes)

N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!