Guest User

Untitled

a guest
Jan 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. package inlamning1;
  2.  
  3.  
  4.  
  5. import java.util.Scanner;
  6.  
  7.  
  8. public class Naming
  9. {
  10.  
  11. public static void main(String[] args)
  12. {
  13.  
  14. //Skapa läsobjektet.
  15. Scanner input = new Scanner(System.in);
  16. //Skapa variablerna
  17. String wordOne;
  18. String wordTwo;
  19. String wordsTogether;
  20. int textLength;
  21.  
  22.  
  23. //Ta in orden att jobba med.
  24. System.out.print("Skriv in ett ord: ");
  25. wordOne = input.nextLine();
  26.  
  27. System.out.print("Skriv ytterligare ett ord: ");
  28. wordTwo = input.nextLine();
  29.  
  30.  
  31. //Lägger ihop den slutliga strängen och räknar ut längden på antalet bokstäver.
  32. wordsTogether = wordOne + " " + wordTwo;
  33. textLength = wordsTogether.length();
  34.  
  35.  
  36. //Så skriver vi ut allt.
  37. System.out.print(wordsTogether + "\n" + textLength + "\n");
  38.  
  39. }
  40.  
  41.  
  42. }
Add Comment
Please, Sign In to add comment