login  Naam:   Wachtwoord: 
Registreer je!
 Forum

fout in java

Offline Nopda - 12/06/2006 11:55 (laatste wijziging 12/06/2006 12:07)
Avatar van NopdaLid code

  1. public class Simulatie
  2. {
  3.  
  4. public static int gooi()
  5. {
  6. int ogen;
  7. ogen=(int)(1+6*Math.random());
  8. return ogen;
  9. }
  10.  
  11. public static void main(String[] args)
  12. {
  13.  
  14. int[] numbers = createArray();
  15.  
  16. System.out.println("de getallen waren ");
  17.  
  18.  
  19.  
  20. int[] counts = countNumbers(numbers);
  21. System.out.println("");
  22. displayCounts(counts);
  23.  
  24. }
  25.  
  26. public static int[] createArray()
  27. {
  28. int[] numbers= new int[100];
  29.  
  30. for(int i=0;i< numbers.length; i++)
  31.  
  32.  
  33. numbers[i] = gooi();
  34. return numbers;
  35.  
  36.  
  37. }
  38.  
  39. public static void displayArray (int[] numbers)
  40. {
  41. for(int i=0;i< numbers.length; i++)
  42. {
  43. if ((i +1)%20 ==0)
  44. System.out.println(numbers[i]+ "");
  45. else
  46. System.out.println(numbers[i]+ "");
  47. }
  48. }
  49.  
  50. public static int[] countNumbers(int[] numbers)
  51. {
  52. int[] counts = new int[12];
  53.  
  54. for (int i =0;i <numbers.length; i++)
  55.  
  56. counts[numbers[i]-'1']++;
  57.  
  58. return counts;
  59.  
  60. }
  61.  
  62. public static void displayCounts(int[] counts)
  63. {
  64. for (int i =0;i <counts.length; i++)
  65. {
  66. if ((i+1)%10==0)
  67. System.out.println(counts[i] + "" +(numbers) (i + '1'));
  68. else
  69. System.out.println(counts[i] + "" + (numbers) (i + '1')+"");
  70. }
  71. }
  72.  
  73. }

foutmelding

:\Simulatie.java:68: cannot find symbol
symbol : class numbers
location: class Simulatie
System.out.println(counts[i] + "" +(numbers) (i + '1'));
^
C:\Simulatie.java:70: cannot find symbol
symbol : class numbers
location: class Simulatie
System.out.println(counts[i] + "" + (numbers) (i + '1')+"");

pls help^^

2 antwoorden

Gesponsorde links
Offline Ontani - 12/06/2006 12:06
Avatar van Ontani Gouden medailleGouden medailleGouden medailleGouden medaille

-1
public static void displayCounts(int[] counts)

moet dat niet worden:

public static void displayCounts(int[] counts, int[] numbers)
Offline Nopda - 12/06/2006 14:15 (laatste wijziging 12/06/2006 15:39)
Avatar van Nopda Lid het was het niet maar toch thnx



code
  1. public class Simulatie
  2. {
  3.  
  4. public static int gooi()
  5. {
  6. int ogen;
  7. ogen=(int)(1+6*Math.random());
  8. return ogen;
  9. }
  10.  
  11. public static int gooi2()
  12. {
  13. int ogen;
  14. ogen=(int)(1+6*Math.random());
  15. return ogen;
  16. }
  17.  
  18. public static void main(String[] args)
  19. {
  20. int[] numbers = createArray();
  21. System.out.println("SIMULATIE door NORBERT SCHILD");
  22. System.out.println("_______________________________");
  23. System.out.print("de simulatie zorgde voor het volgende resultaat\n");
  24. displayArray(numbers);
  25. int[] counts = countNumbers(numbers);
  26. System.out.println("" );
  27. displayCounts(counts,numbers);
  28. }
  29.  
  30. public static int[] createArray()
  31. {
  32. int[] numbers= new int[100];
  33. for(int i=0;i< numbers.length; i++)
  34. numbers[i] = gooi()+gooi2();
  35. return numbers;
  36. }
  37.  
  38. public static void displayArray (int[] numbers)
  39. {
  40. for(int i=0;i< numbers.length; i++)
  41. {
  42. if ((i +1)%20 ==0)
  43. System.out.println(numbers[i]+", ");
  44. else
  45. System.out.println(numbers[i]+",");
  46. }
  47. }
  48.  
  49. public static int[] countNumbers(int[] numbers)
  50. {
  51. int[] counts = new int[13];
  52. for (int i =0;i <numbers.length; i++)
  53. counts[numbers[i]+0]++;
  54. return counts;
  55. }
  56.  
  57. public static void displayCounts(int[] counts,int[] numbers)
  58. {
  59. for (int i =2;i <counts.length; i++)
  60. {
  61. if (counts[i]<100)
  62. System.out.println(counts[i] + " keer " + i /*+(numbers[i - 1])*/);
  63.  
  64.  
  65. else
  66. System.out.println("");
  67. //System.out.println(counts[i] + " keer " +(numbers[i + 1]+""));
  68.  
  69. }
  70.  
  71. }
  72.  
  73. }


Citaat:
Rensjuh edit:
Codetags gebruiken!
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.195s