Hi,
Please find below the requirement details:
1)Enter the number of carriers:
2(say)
2)Enter the details of carrier1:
15(amount of time taken to deliver an item
125.50(cost to deliver an item
3)Enter the details of carrier2:
12
150.50
But when i am trying to run the loop, the code prints till the integer details of carrier2 and while going to the double details arrayindexoutofbound exception is generated.
Code:
public class sample{
int a;
public static void main(String args[])
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of carriers");
a = sc.nextInt();
int[] b = new int[];
double[] c = new Double[];
System.out.println("Enter the carriers details:");
for(i=0;i<a;i++){
b = sc.nextInt();
c = sc.nextDouble();
}
But when i run the code for say a=2, instead of printing the double value of 2nd carrier arrayindexoutofbound error is displayed.
Can you please let me know where i am getting wrong in the concept?
Thanks in advance.