package labWork6; import java.util.Scanner; public class Main { public static void main(String[] args) { Product a = new Product(1, 5, 10); Scanner in = new Scanner(System.in); int b, c, d, e; menu(); int choice = in.nextInt(); while (true) { switch (choice) { case 1: System.out.println("11"); e = in.nextInt(); a.setCode(e); break; case 2: b = in.nextInt(); a.setPriceForKG(b); break; case 3: c = in.nextInt(); a.setWeight(c); break; case 4: System.out.println( "Код продукта: " + a.getCode() + "Цена за кг: " + a.getPriceForKG() + "Вес продукта: " + a.getWeight()); break; case 5: System.out.println(a.getResult()); break; case 6: int i = 0; if (i == 0) { System.exit(0); } break; default: break; } } } public static void menu() { System.out.println(" Меню "); System.out.println("1.Установить значение кода"); System.out.println("2.Установить значение цены за 1 кг"); System.out.println("3.Установить значение веса"); System.out.println("4.Вывод данных на экран"); System.out.println("5.Вывод Результата(Цена)"); System.out.println("6.Выход из программы"); } } 

Closed due to the fact that off-topic participants are Roman C , 0xdb , Kromster , aleksandr barakin , smellyshovel 16 Oct '18 at 16:47 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - 0xdb, Kromster, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 3
    Do you offer us to guess what is wrong? - ArchDemon 5:57 pm
  • one
    "wholesale out" - wholesale, of course, cheaper - Igor

1 answer 1

add choise to the loop. you have it read only once

  • what are we talking about ?????? - Dmitry Pavlovsky
  • add your int choice = in.nextInt (); in the while block of the cycle - Jackson750
  • all understood, thank you - Dmitry Pavlovsky