Sorry, I do try and explain steps though. I wont post code solutions in future.
Type: Posts; User: djl1990
Sorry, I do try and explain steps though. I wont post code solutions in future.
Try this mate
int A, B;
double C, D, E;
Scanner scan = new Scanner(System.in);
System.out.println("Please enter 2 integers:");
A = scan.nextInt();
You'll need 5 variables
A & B (the two integers read in from user input)
C = A parsed to a double
D = B parsed to a double
and E = C / B
Try it that way.
The key point learnt here i think is converting the ints to doubles before performing the division.
Yes you should try my code above to see if its what youre looking for.
I had the same problem with dividing two integers and trying to just store the result as a double.
it just gave 0.0...
Ah i think its parseDouble you need to convert int to double.
at the moment i have:
package testing;
import java.util.Scanner;
import java.text.DecimalFormat;
to read in user input you need to use the Scanner class.
first of all import the Scanner class: import java.util.Scanner;
then in your main class body you want to create a new scanner object...
so you want to ask the user to type in 2 integers?
then divide the first integer by the second integer? and store this value in a double.
then print out the double to 2 decimal places?