Jump to content
  • Welcome!

    Register and log in easily with Twitter or Google accounts!

    Or simply create a new Huddle account. 

    Members receive fewer ads , access our dark theme, and the ability to join the discussion!

     

Any Programmers out there want to help me with a program for school?


The Saltman

Recommended Posts

its in java and Im having issues getting it to print.

Here is the Question:

Design a class named LinearEquation for a 2 X 2 system of linear equations:

ax + by = e x = (ed – bf)/(ad – bc)

cx + dy = f y = (af – ec)/(ad – bc)

The class contains:

 Private data fields a, b, c, d, e, f.

 A constructor with the arguments for a, b, c, d, e, f.

 Six get methods for a, b, c, d, e, and f.

 A method named isSolvable() that returns true if ad – bc is not 0.

 Methods getX() and getY() that retrun the solution for the equation.

Here is what I got so far the thing is the teacher left out this part of the question on purpose so the user does not have to input anything but im still confused on how to execute the file:

Draw the UML diagram for the class. Implement the class. Write a test program that prompts the user to enter a, b, c, d, e, and f and displays the result. If ad – bc is 0, report that “The equation has no solution.”

so here is what I got so far. im having issues with where to put the main method and how to print it:

public class LinearEquation {

// declare the six coefficient

private static int a;

private static int b;

private static int c;

private static int d;

private static int e;

private static int f;

// a constructor to initial the coefficient

LinearEquation(int inputA, int inputB, int inputC, int inputD, int inputE, int inputF){

a = inputA;

b = inputB;

c = inputC;

d = inputD;

e = inputE;

f = inputF;

}

// method isSolvable to show whether the equations has solution or not

static int isSolvable(){

if(((a*d) - (b*c)) == 0)

return 0;

else

return 1;

}

// method getX() to calculate the solution of x

static double getX(){

return (((e*d) - (b*f))/((a*d) - (b*c)));

}

// method getY() to calculate the solution of y

static double getY(){

return (((a*f) - (e*c))/((a*d) - (b*c)));

}

Link to comment
Share on other sites

Don't you just need 1 more method (public static void main ) that will prompt the user for the 6 variables and then call the methods, and print out the result ?

main can go anywhere. Top, middle bottom. I like it on the bottom, with my constructors on top.

Link to comment
Share on other sites

Use the Scanner class to get input....

public static void main(String[] args) {

System.out.println("The super insano calculator");

Scanner reader = new Scanner(System.in);

System.out.println("Enter the first number");

//get user input for a

int a=reader.nextInt();

// yadda yadda

//repeat for other variables and then call your contructor.

// Then call your methods

// then print

}

Link to comment
Share on other sites

Just make up some terms in the main method.... and then call your constructor, then call methods. Then print. then profit!!

public static void main(String[] args) {

System.out.println("The super insano calculator");

int aa =3;

int bb = 6;

.

.

int ff=8;

LinearEquation myLinearEquation = new LinearEquation(aa, bb, cc, dd, ee, ff);

int solve = myLinearEquation.isSolvable();

double x = myLinearEquation.getx();

double y = myLinearEquation.gety();

// then print .......

}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


  • PMH4OWPW7JD2TDGWZKTOYL2T3E.jpg

  • Topics

  • Posts

    • Man whether it's the Panthers or the Hornets it's crazy how many foolish talking heads there are in the local media. I just unsubscribed from locked on Hornets. Doug Branson with his cheesy mustache is an absolute clown especially when his partner isn't on. Talking about trading LaMelo because he can't win basketball games by himself with no semblance whatsoever of a legitimate Center. These YouTube personalities will say anything for a damn click.
    • I’m hoping for that exact same scenario, two seconds would be big for us. I’d hope for 3 impact players. A WR/DL/DE that can contribute like this current class would be key to our rebuild.
    • When I look at what I can find, a carryover problem from last season is our receivers are still unable to get enough separation on a consistent basis. Canales is certainly better at scheming them open, like how he sneaked out Thielen for a big play. But then he's also having Thielen running routes he frankly shouldn't be doing anymore. I feel part of the RZ issues is not really having anyone - after trading Diontae - who can make those quick cuts on a short field to give whoever is under center a wider window to throw. We also only have one guy with blazing speed in Thompkins and from what I could see, he's really used more to draw away coverage. I bring this all up because what Canales needs for sustained success - other than QB - is the other receiver pieces we'll be getting in the offseason.  Otherwise, I have to say that Canales isn't as afraid to be aggressive offensively. As others mentioned, still doesn't run the ball enough at times. Finally, I still feel his playcalls still doesn't line up with his mantra of getting rid of the ball within x amount of seconds. Maybe I count too slow. Oh, and I'm glad Canales first game after a bye looked good. I feared he'd be like Ron Rivera where we would fall flat on our faces.
×
×
  • Create New...