-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwo_dimesional_product.java
More file actions
32 lines (27 loc) · 1.24 KB
/
Copy pathtwo_dimesional_product.java
File metadata and controls
32 lines (27 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package array;
import java.util.Scanner;
public class two_dimesional_product {
public static void main(String[] args) {
String product[][] = new String[10][5];
int i,n = 0;
double total;
Scanner objin = new Scanner(System.in);
do{
System.out.print("Input number of product :");
n=objin.nextInt();
}while(n>10);
for(i=0;i<n;i++){
System.out.println("================= Product :"+i+" ==================");
System.out.print(" Input ID :");product[i][0]=objin.next();
System.out.print(" Input Name :");objin.nextLine();product[i][1]=objin.nextLine();
System.out.print(" Input Price :");product[i][2]=objin.next();
System.out.print(" Input Qty :");product[i][3]=objin.next();
total = Float.parseFloat(product[i][2]) * Integer.parseInt(product[i][3]);
product[i][4]=String.valueOf(total);
}
System.out.printf("%-12s%-14s%-15s%-13s%-15s\n","ID","Name","Price","QTY","Total");
for(i=0;i<n;i++){
System.out.printf("%-12s%-14s%-15s%-13s%-15s\n",product[i][0],product[i][1],product[i][2],product[i][3],product[i][4]);
}
}
}