Hey guys, this is my first time posting, registered 5 mins ago.
I am trying to make a program which allows the user to input letters, from A to F. when the user enters an empty sentence, the program is to print statistics to each letter. i.e:
Enter letters: ABAB
Enter letters: CBBBC
Enter letters: DEDF
Enter letters: AA
Enter letters:
Statistics:
A: 4
B: 5
C: 2
D: 2
E: 1
F: 1
my program looks like this, so far;
import java.util.Scanner;
It's the while loop which gives me problems. I need the right condition. I want the while loop to run, as long as the string expands. if the user enters an empty sentence, the program should exit the while loop and print the statistics. Any thoughts about what condition I should set in the while loop?Code:public class Karakterstatistikk {
public static void main(String args[]) {
String karakterer = "";
int primitiv = Integer.parseInt(karakterer);
Scanner tastatur = new Scanner(System.in);
System.out.println("Karakterstatistikk.");
System.out.println("Innlesing avsluttes med tom linje.");
System.out.print("Angi karakterer for student:");
karakterer += tastatur.next();
System.out.println();
while (user.input > 0 ) {
System.out.print("Angi karakterer for student:");
karakterer += tastatur.next();
System.out.println();
System.out.println(karakterer);
System.out.println(primitiv);
I am from norway btw, therefore I have a lot of the program written in norwegian.
Thanks.

