Results 1 to 3 of 3
Thread: Help?!
- 04-07-2012, 03:50 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
Help?!
Please, why it doesn't work?
Java Code:package lista.vetores; import java.util.*; public class Ex2 { public static void main(String args[]){ Scanner sc = new Scanner(System.in); float vet [] = new float[15]; int i = 0; float maior = 0; float menor = 1000000; while(i<15) {System.out.println("input number":) vet [i] = sc.nextFloat(); i++; if (Arrays.binarySearch(vet, i)>M) {M = vet[i];} else { if (Arrays.binarySearch(vet, i)<m) {m = vet[i];} } } System.out.println(" most of 15:"+M+" "+"smallest of 15:"+m); } }
Last edited by Hounted; 04-07-2012 at 04:07 PM.
-
Re: Help?!
Some suggestions to help you get better help here:
- Please use a thread title that tells us something about the underlying nature of your problem. "help" tells us nothing we don't already know -- you wouldn't be posting a question here if you didn't need help. Think of the thread title as being similar to the headline of a newspaper article -- a single small sentence that summarizes all.
- Please explain just how your code is not working? Does it compile? run? give bad results?
- If you get any error messages, please post their full text.
- Please use [code] [/code] tags around your code so it retains its format and is readable.
Good luck and welcome here.
- 04-07-2012, 04:05 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
Re: Help?!
sorry
if i put him to work he will ask for the 15 values and results to an error
when i remove those parts with if and else the code work... but i need him to work with then...
at the end it show
Java Code:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 15 at lista.vetores.Ex2.main(Ex2.java:26) Java Result: 1
Last edited by Hounted; 04-07-2012 at 04:10 PM.
Bookmarks