Define a class to model linear equation of variables x and y

Assignment Help JAVA Programming
Reference no: EM13974093

This assignemnt is super easy if you know java. You will need is to add any fields that are required for the class to work properly and fill in definitions for the given methods. Just follow the instructions provided in the attached file. I can email you the test file afterwards.

Files to submit

SlopeInterceptLE.java

Define a class to model a linear equation of variables x and y in slope intercept form. A skeleton for this file is provided in the project pack.

SlopeInterceptLETests.java

Provides tests of the correctness of the above class.

3.1 Good old Em ex plus Bee

A linear equation is in slope intercept form if it is written

y=mx+b

where m and b are constants that do not change while x and y are variables that do change.

Define a class which models a linear equation in slope intercept form. A template is provided for you in the fileSlopeInterceptLE.java. You will need to add any fields that are required for the class to work properly and fill in definitions for the below methods.

3.2 Class Structure of SlopeInterceptLE

// A class to model linear equations of two variable (x and y) in
// slope intercept form.

public class SlopeInterceptLE {

// Public constructor that accepts values for the slope m and
// intercept b, defaults the value of x to 0.0 and sets y
// appropriately.

publicSlopeInterceptLE(double m, double b);

// Public constructor that accepts values for the slope m and
// intercept b and initial value of x and sets y appropriately.

publicSlopeInterceptLE(double m, double b, double x);

// Return the numeric value of the equation which is the numeric
// quantity that should be on both left and right sides of the equal
// sign.

public double value();

// Return the current value of x

public double getX();

// Return the current value of y

public double getY();

// Set the value of x and change y accordingly to preserve the
// equation.

public void setX(double x);

// Set the value of $y$ and change $x$ accordingly to preserve the
// equation.

public void setY(double y);

// Return a =String= version of the general form of the equation.
// The pretty version's general format should be as follows.
// y = M.MM * x + B.BB
// M.MM is the slope with 2 digits of accuracy and B.BB is the
// intercept with two digits of accuracy. Look for a method of the
// String class to assist with formatting.
// Examples:
// y = 1.23 * x + 122.41
// y = -1.23 * x + -122.41

public String toString();

}

3.3 Implementation Notes

The method

public String toString()

should return a String version of the general form of the equation. This string's general format should be

y = M.MM * x + B.BB

where M.MM is replaced with the value of m with 2 decimal digits of accuracy and similarly for B.BB being replaced by b. For example, if m=1.23,b=122.408, the appropriate string to produce is

y = 1.23 * x + 122.41

If m=-1.23,b=-122.408, the appropriate string to produce is

y = -1.23 * x + -122.41

This task is significantly easier if you examine the String.format() method and learn a few things about format strings for producing nice looking output. Format strings are used with System.out.printf() which is derived from the C language printf function. There are several places to learn about them.

3.4 Sample Session

Welcome to DrJava. Working directory is /...

>SlopeInterceptLEsi = new SlopeInterceptLE(1.0,2.0)
>si
y = 1.00 * x + 2.00
>si.toString()
y = 1.00 * x + 2.00
>si.getX()
0.0
>si.getY()
2.0
>si.value()
2.0
>si.setX(4)
>si.value()
6.0
>si.getY()
6.0
>si
y = 1.00 * x + 2.00
>si.toString()
y = 1.00 * x + 2.00
>si = new SlopeInterceptLE(0.25, 10.25, 1.0);
>si.getX()
1.0
>si.getY()
10.5
>si
y = 0.25 * x + 10.25
>si.setY(4.5)
>si.getY()
4.5
>si.getX()
-23.0
>si
y = 0.25 * x + 10.25
>si.value()
4.5
>si = new SlopeInterceptLE(-0.25, -10.25, -1.0);
>si.toString()
y = -0.25 * x + -10.25
>si = new SlopeInterceptLE(0.67512, -1.999, -1.0);
>si.toString()
y = 0.68 * x + -2.00

Reference no: EM13974093

Questions Cloud

Describe digital forensics and process management. : Consider that Data Security and Policy Assurance methods are important to the overall success of IT and Corporate data security.
What do the major career interest inventories test for : Often, one of the first tasks in career counseling is determining client interests. Instead of simply asking clients what kind of work they are interested in, career interest inventories can be hundreds of questions long. What do the major career ..
What should the order size be every time that an order : The annual demand is 250 sheets. What should the order size be every time that an order is placed to minimize total annual cost?
What is the annual ordering cost : If annual demand is 24,000 units, orders are placed every 0.5 months, and the cost to place an order is $50, what is the annual ordering cost?
Define a class to model linear equation of variables x and y : Define a class to model a linear equation of variables x and y in slope intercept form. A skeleton for this file is provided in the project pack.
Education expenses-interest on higher education : Federal Tax Question Lionel is an unmarried law student at State University Law School, a qualified educational institution. This year Lionel borrowed $24,000 from Counti Bank and paid interest of $1,440. Lionel used the loan proceeds to pay his l..
How many units of inventory must their storage area : How many units of inventory must their storage area be able to hold?
Social cognition and research design : Blended Learning: Social Cognition & Research Design- "Priming" happens when a thought, image, emotion, memory, etc. becomes salient in the mind due to some internal or external stimulus. Spreading activation triggers related concepts in the mind ..
Determine some of the privacy problems related to biometrics : Which method(s) of biometrics that would not meet with undue resistance from potential users would you recommend to a manager to replace password-based access controls?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a scatterplot visualization

Create a Scatterplot visualization that reads data from a comma-separated text file. The visualization code should be written in Java using Processing.

  The 7th test of credits

The 7th test of credits? this is the 7th test of credits? this is the 7th test of credits? this is the 7th test of credits?this is the 7th test of credits?this is the 7th test of credits?this is the 7th test of credits?this is the 7th test of credits..

  An infix to postfix method for my java program.

an infixToPostFix method for my java program. The method must work with stacks and it should take a string as parameter. The method should be able to convert to postfix mathematic expressions such as: (12 + 4) - 23(9-6)/12. Treat the parenthesis as l..

  Implement 1-parameter date constructor that receives string

Date objects should store the date in two int instance variables: day and month, and it should include the String instance variable, error, initialized with null.

  Create java program to simulate the operation of a bank atm

write a Java program to simulate the operation of a bank ATM (cashpoint) system for payment and deposit on an account. In order to make the system fairly simple there is only one bank account and there are 5 cards that can be used to deposit or wi..

  Promgraming 1 1 there are many different concepts

1. 1 there are many different concepts associated with oop object-oriented programming like class

  Which parts of the assignment were you not able to complete

Which parts of the assignment were you not able to complete fully? For each, explain why you were unable to complete this part and what steps you took to attempt to complete it. Give me as much detail as possible such that I may award partial cred..

  Create a project using the classes in the doc sharing area

create a project using the classes in the Doc Sharing area labeled A Simple LinkedList class. Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture.

  Code layout, use of variable names highlight the java code

Java Code high-lighting, things like code layout, use of variable names, general readability and understandability

  Design and implement an applet that plays a simple game

Design and implement an Applet that plays a simple game to help teach a child to read. The game displays a picture on the left hand side of the Applet and a word on the right hand side. Below the pictures are two buttons for the child to click--on..

  Write an application class that contains several methods

Write a driver class. This class should use the main method to call four methods in the application class that will display our JOptionPanes - Write an application class that contains several methods.

  Write a program that evaluates the day of the week for new

write a program that evaluates the day of the week for new years day in the year 3000. to do this you must create your

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd