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

    • Remember Freddie played barely any of the season. Less than 20% of the overall goalie starts.
    • Official Website @> https://www.facebook.com/people/Glyco-Care-Canada/61560357188713/   Glyco Care Canada;- examinations, it can improve and support mind processes. Biotin can likewise assist with hair development.   Official FB @> https://www.facebook.com/people/Glyco-Care-Canada/61560802160323/    https://glyco-care-canada-9.jimdosite.com/   https://glyco-care-canada-10.jimdosite.com/   https://glyco-care-canada-5.jimdosite.com/   https://glyco-care-canada-6.jimdosite.com/   https://glyco-care-canadabuy.company.site/   https://glycocarecanadareviews.company.site/   https://medium.com/@GlycoCareCanada/glyco-care-canada-reviews-behind-secret-glyco-care-reviews-side-effects-and-where-to-buy-0bdeba268b7e   https://medium.com/@shirleygsmiths/glyco-care-canada-reviews-news-alert-blood-balance-glyco-care-warning-86e6756f1ecc   https://medium.com/@shirleygsmiths/glyco-care-canada-reviews-is-fake-or-real-glyco-care-reviews-read-about-product-100-natural-6e359bb619e5   https://medium.com/@shirleygsmiths/glyco-care-canada-reviews-legit-scam-alert-glyco-care-reviews-worth-to-buying-read-carefully-8fecb0d2cdb2   https://medium.com/@shirleygsmiths/glyco-care-canada-reviews-reviews-2024-beware-glyco-care-reviews-ca-shocking-legit-warning-c02a7f405460   https://infogram.com/glyco-care-canada-reviews-behind-secret-glyco-care-reviews-side-effects-and-where-to-buy-1h0n25oodepml4p   https://shirleygsmith.clubeo.com/calendar/2024/06/04/glyco-care-canada-reviews-scam-exposed-2024-glyco-care-reviews-read-before-buy   https://shirleygsmith.clubeo.com/calendar/2024/06/05/glyco-care-canada-reviews-news-alert-is-it-real-or-trusted-universal-overview-trend   https://shirleygsmith.clubeo.com/calendar/2024/06/04/glyco-care-canada-reviews-news-alert-blood-balance-glyco-care-warning-is-it-scam-or-legitimate   https://granadinistas.ideal.es/news/glyco-care-canada-reviews-latest-update-2024-is-it-worth-to-buy   https://narede.clicrbs.com.br/articles/glyco-care-canada-reviews-warning-important-information-no-one-1   https://community.goldencorral.com/news/glyco-care-canada-reviews-latest-update-2024-glyco-care-is-it-wor   https://network.propertyweek.com/articles/glyco-care-canada-reviews-fraudulent-warning-2024-beware-glyco-ca   https://fms.microsoftcrmportals.com/forums/general-discussion/6e1731e5-2923-ef11-8ee7-000d3aa0963b   https://exclusiondev.dynamics365portals.us/forums/general-discussion/2a94f8ef-2623-ef11-a296-001dd8097855   https://nycourts-dev.powerappsportals.us/forums/general-discussion/e738ed90-2723-ef11-a296-001dd8051edf   https://ocsheriff.dynamics365portals.us/forums/general-discussion/25d8e45a-2823-ef11-a295-001dd804e445   https://hpdcrmportal.dynamics365portals.us/forums/general-discussion/281610cb-2823-ef11-a295-001dd805e213   https://twor.microsoftcrmportals.com/forums/general-discussion/b113e43c-2923-ef11-8ee7-00224811ea47   https://uoc-sandbox.powerappsportals.us/en-US/forums/general-discussion/e6e2a36a-2923-ef11-a296-001dd8095c57   https://thecontingent.microsoftcrmportals.com/forums/general-discussion/9987f4b3-2923-ef11-8ee7-0022480a4e2f
    • Kupp didn't win them a SB, the Stafford trade did. No WR is carring a SB. Kupp just showd his QB wasn't it so they went and got it. Hill is proving Tua ain't it either but it looks like Miami will pay him anyways. I said it's all about the QB and then the rest. The WRs just help those QBs and should help the team evaluate their QBs. Purdy just failed big time and that is a stacked roster. If the Viks new QB can't be it with Jefferson then he doesn't stand a chance without him. It's not about the WR carrying the team to a SB but the WR setting the young QB up for success and making it easy to eevaluateif they are it because that is the most important part of building a modern SB champ. They overspent but it was a luxury they could afford. If you think bringing in a rookie QB and letting your best WR go in the process then you didn't learn anything from the Moore debacle. If Young had a legit WR last year then half the BS about not knowing would be gone this year. I would rather pay to know then just hope. In a perfect world the organization could draft well enough to set up a Cheifs Mahhomes rookie cast or the 49ers but those are really the exceptions and not the rule, the dream I guess.
×
×
  • Create New...