Results 1 to 10 of 10
- 08-06-2012, 12:32 AM #1
Member
- Join Date
- Aug 2012
- Posts
- 4
- Rep Power
- 0
-
Re: How to make user input be of the type double?
How do you declare your array, arr? is it double[] arr or int [] arr?
- 08-06-2012, 01:09 AM #3
Member
- Join Date
- Aug 2012
- Posts
- 4
- Rep Power
- 0
Re: How to make user input be of the type double?
it's double[]
-
Re: How to make user input be of the type double?
- 08-06-2012, 01:23 AM #5
Member
- Join Date
- Aug 2012
- Posts
- 4
- Rep Power
- 0
Re: How to make user input be of the type double?
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
System.out.println("Enter array size: ");
int n = sc.nextInt();
double[] arr = new double[n];
double min = 0;
for(double i = 0; i <n; i++){
System.out.println("Enter element " + (i + 1));
arr[i] = sc.nextDouble();
if(i%3 == 0 && i <= min){
min = i;
}
}
if(min != 0){
System.out.println("The smallest number divisible by 3 is" + min);
}
else{
System.out.println("No number is divisible by 3");
}
}
so i had to be int
- 08-06-2012, 01:36 AM #6
Re: How to make user input be of the type double?
Why do they call it rush hour when nothing moves? - Robin Williams
- 08-06-2012, 01:38 AM #7
Re: How to make user input be of the type double?
Why exactly did you declare your for-loop index as of type double?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
-
Re: How to make user input be of the type double?
- 08-06-2012, 06:08 AM #9
- 08-06-2012, 09:24 AM #10
Similar Threads
-
Change the integer variable to type double - is this right?
By Keke101 in forum New To JavaReplies: 1Last Post: 01-02-2012, 11:16 PM -
how to make the check button get user input and display it
By ashraf in forum AWT / SwingReplies: 2Last Post: 09-27-2011, 06:46 PM -
double type format
By eleda in forum New To JavaReplies: 4Last Post: 09-17-2010, 07:23 AM -
is Math.pow only used with type double?
By AprilFlowers in forum New To JavaReplies: 9Last Post: 10-23-2009, 04:38 AM -
Help with convert a double type number
By trill in forum New To JavaReplies: 1Last Post: 08-06-2007, 08:48 AM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks