-2

In Java,I need to ask user input for two integers. The program needs to divide by these two integers and produce a decimal to the sixth place. I know that i will need to name two integers: numerator and denominator. Also, I need to name a double variable: result.

Thanks for the help!!

  • Please show us what you have tried or a code sample, along with an explanation of why it didn't work. Thank you. – soktinpk Oct 27 '14 at 03:09

1 Answers1

-1

You haven't given any clues as to the language or platform you are using, but here is a basic example written in C running on a console.

#include <stdio.h>

int main()
{
int num, den;
double quo;

    printf("Enter numerator: ");
    scanf("%d", &num); 
    printf("Enter denominator: ");
    scanf("%d", &den); 
    if (den == 0)
        printf("Divide by zero\n");
    else {
        quo = (double)num / (double) den;
        printf("Quotient = %.6f\n", quo);
        }
    return 0;
}
Weather Vane
  • 33,872
  • 7
  • 36
  • 56