University stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HeiStudent.java 952B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import java.util.Scanner;
  2. class HeiStudent {
  3. private static void a() {
  4. System.out.println("Hei student!");
  5. }
  6. private static void b() {
  7. String name = "Martin";
  8. System.out.println("Hello, "+name);
  9. }
  10. private static void c() {
  11. //Asks the user what age they are, printing the name back to them
  12. System.out.println("What's your name?");
  13. Scanner s = new Scanner(System.in);
  14. System.out.println("Hello "+s.nextLine());
  15. }
  16. private static void d() {
  17. int a = 10;
  18. int b = 200;
  19. System.out.println(a+"+"+b+"="+(a+b));
  20. }
  21. private static void e() {
  22. Scanner s = new Scanner(System.in);
  23. //Asks the user for two number
  24. System.out.println("Write a number.");
  25. int a = s.nextInt();
  26. System.out.println("Write another number.");
  27. int b = s.nextInt();
  28. //Tells the user the sum of the numbers they entered
  29. System.out.println(a+"+"+b+"="+(a+b));
  30. }
  31. public static void main(String[] args) {
  32. a();
  33. b();
  34. c();
  35. d();
  36. e();
  37. }
  38. }