sorry, I think the way I described the problem above it just confusing as hell, haha. Here's a better description: I have a program that takes 2 numbers from a user and calculates their sum and product. Then it asks how many decimal places to show, then print out the sum and product showing only that many decimal places (if the sum is 0.23546547665, and the user enters 3, then I want it to print 0.235). Here's the program that I have so far:

Code:

import java.util.Scanner; // Needed for the Scanner class.
public class Floating_And_Fixed
{
public static void main(String[] args)
{
double[] values = new double[2]; // The number input by the user.
double sum, product; // The sum and product of the two numbers.
int precision; // The user defined number of decimal places to display.
// Used to get input.
Scanner keyboard = new Scanner(System.in);
// Get the two numbers from the user.
for (int index = 0; index <= 1; ++index)
{
System.out.print("Please enter value number " +
(index + 1) + " : ");
values[index] = keyboard.nextDouble();
}
// Calculate the sume and product.
sum = calcSum(values[0], values[1]);
product = calcProduct(values[0], values[1]);
// Ask how many decimal places the user would like to be displayed.
System.out.printf("\nHow many decimal places would you like to be displayed?\n\n");
precision = keyboard.nextInt();
// Consume the remaining newline.
keyboard.nextLine();
// Print the sum and product.
System.out.printf("Sum:\n---------------------\nFixed-Point Notation: %f\n\n", sum);
System.out.printf("Product:\n---------------------\nFixed-Point Notation: %f", product);
}
public static double calcSum(double value1, double value2)
{
double sum;
sum = value1 + value2;
return sum;
}
public static double calcProduct(double value1, double value2)
{
double product;
product = value1 * value2;
return product;
}
}