Click here to Skip to main content
15,891,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm starting a program and two of the requirements are these and I don't know where to start?

1. Default value constructor that sets the numerator to 1 and the denominator to 1
2. Explicit value constructor that sets the numerator and denominator to values specified by the user

What I have tried:

Java
import java.util.*;
public class Rational
{
	int numerator = 1;
	int denominator = 1;
	Scanner kb = new Scanner(System.in);
	System.out.print("Please enter a numerator: ")
	numerator = kb.nextInt();
	System.out.print("Please enter a denominator: ")
	denominator = kb.nextInt();
}
Posted
Updated 6-Mar-17 15:29pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900