I am getting lot of IOErrror
Exception in thread “main” java.util.NoSuchElementException
NumberFormatException.
So far I tried Scanner Reader, BufferedReader but IOErrors everytime
Getting IOError Exception many times
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 1 ;i<n; i++)
{
if(i%2 != 0)
{
for(int j = 1;j<=i; j++)
{
System.out.print(1);
}
}
else
{
System.out.print(1);
for(int j = 0;j<i-2;j++)
System.out.print(0);
System.out.print(1);
}
System.out.println();
}
}
}
Got again IOError , Please help how to rectify it.
indent preformatted text by 4 spaces
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
double a = sc.nextDouble();
double b = sc.nextDouble();
double c = sc.nextDouble();
double root = Math.pow(b,2)-4*a*c;
if(root<0) System.out.println("Imaginary");
else
{
root = Math.sqrt(root);
double val1 = -b-root/2*a;
double val2 = -b+root/2*a;
if(val1 == val2)
{
System.out.println("Real and Equal");
System.out.println((int)val1+" "+(int)val1);
}
else{
System.out.println("Real and Distinct");
System.out.println((int)Math.min(val1,val2)+" "+(int)Math.max(val1,val2));
}
}
}
}
Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at Main.main(Main.java:5)