- Suppose that the text file on the Web http://cs.armstrong.edu/liang/data/Scores.txt contains an unspecified number of scores. Write a program that reads the scores from the file and displays their total and average. Scores are separated by blanks.
- In a triangle, the sum of any two sides is greater than the other side. Create an IllegalTriangleException class. Write a Triangle Class with the constructor of the Triangle class designed to throw an IllegalTriangleException object if a triangle is created with sides that violate the rule, as follows:
/** Construct a triangle with the specified sides */

public Triangle(double side1, double side2, double side3) {

throws IllegalTriangleException

// Implement it

}

- (Plot functions using abstract methods) Write an abstract class that draws the diagram for a function. The class is defined as follows:

abstract class AbstractDrawFunction extends JPanel {

/** Polygon to hold the points */

private Polygon p = new Polygon();

final int TO_X_AXIS = 125;

final int TO_Y_AXIS = 125;

final int END_OF_X_AXIS = 275;

final int END_OF_Y_AXIS = 200;

protected AbstractDrawFunction () {

drawFunction();

setBackground(Color.white);

}

/** Return the y-coordinate */

abstract double f(double x);

/** Obtain points for x-coordinates 100, 101, . . ., 300 */

public void drawFunction() {

for (int x = -100; x <= 100; x++) {

p.addPoint(x + TO_Y_AXIS, TO_X_AXIS – (int)f(x));

}

}

@Override /** Draw axes, labels, and connect points */

protected void paintComponent(Graphics g) {

super.paintComponent(g);

// Draw x axis

g.drawLine(10, TO_X_AXIS, END_OF_X_AXIS, TO_X_AXIS);

// Draw y axis

g.drawLine(TO_Y_AXIS, 30, TO_Y_AXIS, END_OF_Y_AXIS);

// Draw arrows on x axis

g.drawLine(END_OF_X_AXIS, TO_X_AXIS, END_OF_X_AXIS – 20, TO_X_AXIS – 10);

g.drawLine(END_OF_X_AXIS, TO_X_AXIS, END_OF_X_AXIS – 20, TO_X_AXIS + 10);

// Draw arrows on y axis

g.drawLine(TO_Y_AXIS, 30, TO_Y_AXIS – 10, 50);

g.drawLine(TO_Y_AXIS, 30, TO_Y_AXIS + 10, 50);

// Draw x, y

g.drawString(“X”, END_OF_X_AXIS – 20, TO_X_AXIS – 30);

g.drawString(“Y”, TO_Y_AXIS + 20, 40);

// Draw a polygon line by connecting the points in the polygon

g.drawPolyline(p.xpoints, p.ypoints, p.npoints);

}

}

public class draw_graph extends JFrame {

public static void main(String[] arg) {

draw_graph dg = new draw_graph();

dg.setSize(400,400);

dg.setTitle(“Graph”);

dg.setLocationRelativeTo(null);

dg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

dg.setVisible(true);

}

draw_graph () {

setLayout(new GridLayout(1, 3, 1, 1));

// Create your derived class object here

}

}

Test the class with the following functions defined in concrete classes:

a. f(x) = x*x;

b. f(x) = sin(x);

c. f(x) = cos(x);

d. f(x) = tan(x);

e. f(x) = cos(x) + 5*sin(x);

f. f(x) = 5*cos(x) + sin(x);o

g. f(x) = log(x) + x*x;

For each function, create a class that extends the AbstractDrawFunction

class and implements the f method.

Your output should consist of screen shots of plots for these functions with the label of the plot as your name_idnumber.

**For a custom paper on the above topic, place your order now!**

**What We Offer:**

**• On-time delivery guarantee**

**• PhD-level writers**

**• Automatic plagiarism check**

**• 100% money-back guarantee**

**• 100% Privacy and Confidentiality**

**• High Quality custom-written papers**