user image

Rahul Pandit.
Published in : 2022-03-05

I cannot get two different input in the loop, howerver if at first I define int n = 1, it works [closed]

Javascript

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.

Improve this question

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();
    }
}

Comments

Shilpa Date : 2022-03-05

Best answers

10

Best answers

10

The default value of int is 0.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How to get audio input and audio output as one stream?
Publish date: 2022-02-13 | Comments: 1

Tag: Javascript

How to open URL in new tab & focus on it in Javascript?
Publish date: 2021-12-22 | Comments: 1

Tag: Javascript

Can I read a local json, image or text file from Javascript?
Publish date: 2022-03-03 | Comments: 1

Tag: Javascript

Adding an id number at the first index to an array of objects
Publish date: 2022-02-13 | Comments: 1

Tag: Javascript

Check if div have touch another div
Publish date: 2022-03-02 | Comments: 1

Tag: Javascript

Can we add a javascript or jQuery to the URL?
Publish date: 2022-03-05 | Comments: 2

Tag: Javascript

How to toggle ( show and hide ) divs according to day hours?
Publish date: 2022-02-13 | Comments: 1

Tag: Javascript

JAVASCRIPT: How do I add another key to object?
Publish date: 2022-03-06 | Comments: 3

Tag: Javascript