Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Help me please !!!!!!!!!!!!!!!!

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help me please !!!!!!!!!!!!!!!!

    please help me in this question as soon as possible


    Design and implement a calculator for Fractions. The user should enter one or two fractions depending on the operation. The possible operations are reduce, add, subtract, multiply, or divide.
    The class Fraction should have at least the following methods in addition to instance variables and a constructor:

    //add two fractions
    public Fraction addFraction(Fraction other);
    //subtract two fractions
    public Fraction subtractFraction(Fraction other);
    //multiply two fractions
    public Fraction multiplyFraction(Fraction other);
    //divide two fractions
    public Fraction divideFraction(Fraction other);
    //reduce a fraction
    public void reduceFraction();

    Display a menu with the following options:

    1. Reduce a fraction
    2. Add
    3. Subtract
    4. Multiply
    5. Divide
    6. Quit



    i cannot solve it
    i tried many time
    please help meeeee

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help me please !!!!!!!!!!!!!!!!

    a) One exclamation point is too many b) No one is going to do this for you. Make an effort and you might receive effort in return. c) I recommend reading the link in my signature entitled getting help, and the following link:
    http://www.javaprogrammingforums.com...e-posting.html
    If you get stuck, ask a specific question. Dumping a homework assignment will consistently get you a response similar to this one.

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me please !!!!!!!!!!!!!!!!

    it is not homework
    i did part of it
    i need anyone to help me
    import java.io.*;
    import java.util.*;
    public class Calculator
    {
    public static void main(String[] args) throws IOException

    {
    BufferedReader keyboard = new BufferedReader (new InputStreamReader (System.in));
    String input, input1, input2;
    double num1, num2, answer;
    System.out.println ("\t\t\tWelcome to the calculator!");
    do
    {
    System.out.print ("\nWould you like to Multiply(m), Divide(d), Subtract(s), Add(a)?: ");
    input = keyboard.readLine();
    if (input.equals("m"))
    {
    System.out.print ("Please enter the first number!: ");
    num1 = Double.parseDouble (input1 = keyboard.readLine());
    System.out.print ("Please enter the second number!: ");
    num2 = Double.parseDouble (input1 = keyboard.readLine());
    answer = num1*num2;
    System.out.print ("You chose to multiply."+"\t"+"The Product is: "+answer);
    }
    if (input.equals("d"))
    {
    System.out.print ("Please enter the first number!: ");
    num1 = Double.parseDouble (input1 = keyboard.readLine());
    System.out.print ("Please enter the second number!: ");
    num2 = Double.parseDouble (input2 = keyboard.readLine());
    answer = num1/num2;
    System.out.print ("You chose to divide."+"\t"+"The Dividend is: "+answer);
    }
    if (input.equals("a"))
    {
    System.out.print ("Please enter the first number!: ");
    num1 = Double.parseDouble (input1 = keyboard.readLine());
    System.out.print ("Please enter the second number!: ");
    num2 = Double.parseDouble (input2 = keyboard.readLine());
    answer = num1+num2;
    System.out.print ("You chose to add."+"\t"+"The Sum is: "+answer);
    }
    if (input.equals("s"))
    {
    System.out.print ("Please enter the first number!: ");
    num1 = Double.parseDouble (input1 = keyboard.readLine());
    System.out.print ("Please enter the second number!: ");
    num2 = Double.parseDouble (input2 = keyboard.readLine());
    answer = num1-num2;
    System.out.print ("You chose to subtract."+"\t"+"The Diffrence is: "+answer);
    }
    System.out.print ("\nWould you like another calculation (y/n)?: ");
    input = keyboard.readLine();
    }
    while(input.equals("y"));
    if(input.equals("n"));
    System.exit(0);
    }
    }

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help me please !!!!!!!!!!!!!!!!

    Did you read the links I gave you above? You have not provided any information as to where you are stuck. And, as described in those links, please wrap your code in the code tags - it preserves indenting and makes code readable

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help me please !!!!!!!!!!!!!!!!

    Do you have any specific questions about the program?
    Or errors you do not understand?
    Please post them.

  6. #6
    Junior Member
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me please !!!!!!!!!!!!!!!!

    How can i use these



    //add two fractions
    public Fraction addFraction(Fraction other);
    //subtract two fractions
    public Fraction subtractFraction(Fraction other);
    //multiply two fractions
    public Fraction multiplyFraction(Fraction other);
    //divide two fractions
    public Fraction divideFraction(Fraction other);
    //reduce a fraction
    public void reduceFraction();

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help me please !!!!!!!!!!!!!!!!

    How can i use these
    Not sure what you mean by "use these"

    Are you asking how to call a method? That's pretty basic programming. What problem are you having? Do you need to read your textbook or the tutorial? Go to this site and read up on methods:
    Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    All the methods you've listed take a Fraction object as a parameter and return a Fraction object.