So after I input the numbers needed for the while instruction, it should display the result and then the "Enter your name here:" text. Afterwards I should be able to input text, but apperantly I can't, it just displays the "Hello" message and jumps to the next instruction.
However, if I write the text right after the series of numbers, it works just fine. How can I make the program let me input text after the "Enter your name here" message?
import java.util.Scanner;
public class apples {
public static void main(String[] args) {
Scanner cristi = new Scanner(System.in);
int age= 21, k=10, nr=1, sum=0, val=0;
k=cristi.nextInt();
while(nr<=k){
val=cristi.nextInt();
sum=sum+val;
nr++;
}
sum=sum/k;
System.out.println(sum);
System.out.println(age>50 ? "You are old!" : "You are young!");
tuna tunaObject= new tuna();
System.out.println("Enter the name here: ");
String a= cristi.nextLine();
tunaObject.simpleMessage(a);
System.out.println("Enter first name: ");
String temp= cristi.nextLine();
tunaObject.setName(temp);
tunaObject.afisaj();
}
}