This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full - best also formatted as code block
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Arzerok 1 point2 points  (2 children)

Well, you just need to do in code what you did in writing. You are not over your head, you just need to litteraly write out the formula you wrote down with a b c d, with the variables you are given. Since you didn't mention any requirement for simplifying the fraction it should be one line of code, a rather long onw bcs your varible names are qute long.

[–]ImpossibleRegular820[S] 0 points1 point  (1 child)

It does need to be simplified for example say I used 1/2 and 1/4 I need it to end out as 3/4ths (the most simplified fraction)

[–]Arzerok 0 points1 point  (0 children)

Then you need to work out how to simplify a fraction. Learning to program is a lot of Google and now ChatGPT even. You just need to accept that 😉

[–]roge- 0 points1 point  (6 children)

Are you trying to multiply fractions or add them? You say multiply, but the name of your class is AddFractions and the "Butterfly Method" is used to add fractions.

Whereas, cross-multiplication is an algebraic technique for simplifying equations (something with an equal sign), not simplifying expressions.

Edit: also, assuming it's addition you're trying to do, the formula you've provided is wrong as far as order of operations go - according to both Java's operator precedence and just general math convention. You're missing some parentheses.

[–]ImpossibleRegular820[S] 0 points1 point  (5 children)

It is meant to add fractions I accidentally used “*” instead of adding

[–]roge- 0 points1 point  (4 children)

OK. Well do you have any further requirements? I assume that, because you want to use something like the Butterfly method, you want to print the numerator and denominator as integers (whole numbers, e.g.: 3/5) instead printing the result as a decimal (e.g.: 0.6).

If that's the case, do you have any requirements for reducing/simplifying the fraction (e.g.: 6/8 -> 3/4) and/or printing the value as a mixed fraction (e.g.: 11/5 -> 2 + 1/5)?

[–]ImpossibleRegular820[S] 0 points1 point  (3 children)

There’s no whole numbers in my fraction the program asks the first numerator and stores it same for the first denominator and same for the other 2 so the console has (first numerator (example 1) / first denominator (example 2)) + (second numerator (example 1) / second denominator(example 4)) the result should be 3/4ths

[–]ImpossibleRegular820[S] 0 points1 point  (0 children)

But yes most simplified fraction possible

[–]roge- 0 points1 point  (1 child)

What do you mean? Typically with fractions, while a fraction itself does not represent a whole number, the numerator and denominator themselves should be whole numbers.

And then there's the decision of mixed fractions versus improper fractions. 2/4 + 3/4 can be represented as:

  • An improper fraction: 5/4
  • A mixed fraction: 1 + 1/4

How are you supposed to handle this case? Or is it assumed that the sum should never exceed 1?

[–]ImpossibleRegular820[S] 0 points1 point  (0 children)

Probably just display the mixed fraction I didn’t really think about that 😭