when compiling the program, an error pops up ("variable name, age, weight, height might not have been initialized) How to initialize correctly?
the program should output the values entered above in a separate case
thank you in advance
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
boolean mainLoop=true;
while(true) {
System.out.println("MENU:");
System.out.println("1-Name"+"\n"+"2-Age"+"\n"+"3-Height"+"\n"+"4-Weight"+"\n"+"5-print"+"\n"+"0-Exit"+"\n");
System.out.print("Choose from 1 to 5:");
int s = in.nextInt();
switch (s) {
case 1:
System.out.print("1.Enter name: ");
String name = in.nextLine();
break;
case 2:
System.out.print("2.Enter age: ");
int age = in.nextInt();
break;
case 3:
System.out.print("3.Enter height: ");
int height = in.nextInt();
break;
case 4:
System.out.print("4.Enter weight: ");
int weight = in.nextInt();
break;
case 5:
System.out.println("Name: %s" + name );
System.out.println("Age: %d" + age);
System.out.println("Height:%d" + height + "cm" );
System.out.println("Weight:%d" + weight + "kg" );
case 0:
System.out.print("0.Exit");
return;
default:
System.out.print("Wrong entry!");
break;
}
}
}
}