Rahul Pandit.
Published in : 2022-03-05
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 42 mins ago.
I cannot get two different inputs in the loop, however if at first, I define int n = 1
, it works
import java.util.Scanner;public class Test { public static void main(String[] args) { Scanner Input = new Scanner(System.in); int n = Input.nextInt(); while (n >= 1 && n <=5) { if (n == 1) { System.out.print("Enter a: "); String S1 = Input.nextLine(); System.out.print("Enter b: "); String S2 = Input.nextLine(); System.out.println(S1); System.out.print(S2); } System.out.println(); n = Input.nextInt(); } Input.close(); }}
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Shilpa Date : 2022-03-05
Best answers
10
Best answers
10
The default value of int is 0.