0
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        System.out.println("Enter the name of the film");
        String str = s.nextLine();
        System.out.println("Enter the film budget");
        int a = s.nextInt();
        System.out.println("Enter the running time");
        double b = s.nextDouble();
        System.out.println("Enter the film production house");
        String str1 = s.nextLine();
        System.out.println("Film being screened : " + str);
        System.out.printf("Budget : %d crores", a);
        System.out.printf("\nRunning time : %.2f hours", b);
        System.out.printf("\nProduction : %s", str1);
    }
}

I am getting input for a string, integer, double and again string. However, I am not able to get the "Production" value that I enter.

1 Answers1

3

Do

System.out.println("Enter the film production house");
s.nextLine();
String str1 = s.nextLine();

This is because s.nextDouble() doesn't consume the last newline character of your input so str1 is assigned a "\n" (new line) value

Zingerella
  • 440
  • 2
  • 10