Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public class JonasD extends Primspieler
  2. {
  3.  
  4. public int auswahl(int[] zahlen)
  5. {
  6. int ausgewaehlteZahl = 1;
  7. int höchstePrimZahl = 0 ;
  8. int höchsteZahl = zahlen.length - 1;
  9. int höchsteNormalZahl = 0;
  10. int SummeAllerTeiler = 0;
  11.  
  12. for(int i = 2;i<höchsteZahl;i++)
  13. {
  14. if( isPrim(zahlen[i]) )
  15. {
  16. if(zahlen[i]> höchstePrimZahl)
  17. {
  18. höchstePrimZahl = zahlen[i];
  19. }
  20. }
  21. }
  22.  
  23.  
  24. for(int i = 2;i<=höchsteZahl;i++)
  25. {
  26. if(zahlen[i]> höchsteNormalZahl)
  27. {
  28. höchsteNormalZahl = zahlen[i];
  29. }
  30. }
  31.  
  32.  
  33. if(höchstePrimZahl >= höchsteNormalZahl )
  34. {
  35. ausgewaehlteZahl = höchstePrimZahl;
  36. }
  37.  
  38. else
  39. {
  40. ausgewaehlteZahl = höchsteNormalZahl;
  41. }
  42.  
  43.  
  44. return ausgewaehlteZahl;
  45.  
  46.  
  47. }
  48.  
  49. public static boolean isPrim(int value)
  50. {
  51. for(int i=2 ;i < value;i++)
  52. {
  53. if(value % i==0) return false;
  54.  
  55. }
  56. return true;
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63. public String getPlayerName()
  64. {
  65. return "JonasD"; // Bitte anpassen!
  66. }
  67.  
  68. public long getStudentNumber()
  69. {
  70. return 201823072; // Ihre Spielernummer
  71. }
  72.  
  73. // Bitte nicht vergessen, ein Hochformat-Bild im JPG-Format
  74. // als Datei <Matrikelnummer>.jpg mit einzureichen!
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement