Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Odds {
  4. public static void main(String[] args) {
  5. System.out.println("Zagrajmy w parzyste-nieparzyste!");
  6. System.out.print("Jak masz na imię ?");
  7. Scanner name = new Scanner(System.in);
  8. String imie = name.nextLine();
  9. readType(imie); // Tu jest błąd Error:(9, 9) java: non-static method readType(java.lang.String) cannot be referenced from a
  10. // static context
  11.  
  12. }
  13.  
  14. public void readType(String imie) {
  15. System.out.println("Cześć " + imie + " ! Co wybierasz, parzyste (P) czy nieparzyste (N)?");
  16. Scanner kind = new Scanner(System.in);
  17. String rodzaj = kind.nextLine();
  18. ;
  19. if (rodzaj.equals("P")) {
  20. System.out.print("Wybrałeś parzyste. Komputer będzie miał nieparzyste.");
  21. } else if (rodzaj.equals("N")) {
  22. System.out.print("Wybrałeś nieparzyste. Komputer będzie miał parzyste.");
  23. } else {
  24. readType(imie);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement