Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

ISBN: B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions