Question: I'm in java one and i need help with this program. please follow the directions. I will appreciate your help. thank you. Programming Concepts 1.

I'm in java one and i need help with this program. please follow the directions. I will appreciate your help. thank you.

Programming Concepts

1. Methods 2. do-whileorwhileloop

Assignment Description

You will write a program that converts a fraction to a decimal.

To do this, you must ask the user to input the numerator and denominator, and you will calculate and print out the result.

You must implement the following methods:

The main method

A method to get the numerator

A method to get the denominator

A method to calculate the result

A method to print the result

Assignment Requirements

You must write five total methods: the main() method, plus four more, to complete the program.

Use nextDouble() to get a double from user input.

You must print out the result up to three numbers after the decimal point.

You must re-prompt the user if the denominator is 0.

Assignment Suggestions

1. The main() method a. Declare three variables:

i. double numerator: to store the numerator ii. double denominator: to store the denominator

iii. double result: to store the result of numerator / denominator

b. Call the method getNumerator() and store it into numerator

c. Call the method getDenominator() and store it into denominator

d. Call the method calculateResult() and store it into result, passing in the values of numerator and denominator as arguments

e. Call the method printResult(), passing in result as its argument

2.getNumerator()Noparameters

a.Prompt the user to enter in the numerator

b.Get the number from the user, and store it into a double

c.Return the number (a double)

3. getDenominator()Noparameters

a. Prompt the user to enter in the denominator

b. Get the number from the user, and store it into a double

c. Return the number (a double)

4. calculateResult()Takesintwoparameters,thenumerator(adouble),andthedenominator (a double)

a. Divide the two numbers and store it into a double

b. Return the result (a double)

5. printResult()Takesinoneparameter,theresult(adouble)

a. Print out the result

sample output

user@loki:~$ java Fraction

Enter the numerator: 2

Enter the denominator: 5

The decimal value is 0.400

user@loki:~$ java Fraction

Enter the numerator: 10

Enter the denominator: 5

The decimal value is 2.000

user@loki:~$ java Fraction

Enter the numerator: 1

Enter the denominator: 3

The decimal value is 0.333

user@loki:~$ java Fraction

Enter the numerator: 5

Enter the denominator: 0

Enter the denominator: 0

Enter the denominator: 1

The decimal value is 5.000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!