Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Write a program that uses two classes. The first class is called data and holds x and y coordinates of a point in

  1. image text in transcribed 

1) Write a program that uses two classes. The first class is called "data" and holds x and y coordinates of a point in 2-d space called p1. The second class is called "compute" and holds an array of two pointers to the "data" class. The "compute" class has a function, load(float x, float y, int n), which loads x and y coordinate data into the array at index n. It also has a function, slope(), which computes the slope of the line connecting the two array data coordiantes. It also has a function, print(), which prints the slope result to the screen. Implement a divide by zero exception using throw in the slope() nd/or print() function as appropriate. The exception should, when caught, print "Slope calculation error..." to the screen and exit the function. The program should load the array with some example points and print the slope to the screen using the class functions. Also, test your exception handling by using an infinite slope example and include the results in your homework submission.

Step by Step Solution

3.38 Rating (160 Votes )

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

Introduction To Corporate Finance

Authors: Laurence Booth, Sean Cleary

3rd Edition

978-1118300763, 1118300769

More Books

Students also viewed these Finance questions