Ques- Write a code in Netbeans Java that will ask for item code, Item name and price of 3 items and display all information of all items
import java.util.Scanner;
class App {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
String itemCode[] = new String[10];
String itemName[] = new String[10];
double itemPrice[] = new double[10];
for (int i = 0; i < 3; i++) {
System.out.print("Enter item code: ");
itemCode[i] = keyBoard.nextLine();
System.out.print("Enter item name: ");
itemName[i] = keyBoard.nextLine();
System.out.print("Enter item price: ");
itemPrice[i] = keyBoard.nextDouble();
keyBoard.nextLine();
}
System.out.println();
for (int i = 0; i < 3; i++) {
System.out.println("Item code: " + itemCode[i]);
System.out.println("Item name: " + itemName[i]);
System.out.println("Item price: " + itemPrice[i]);
System.out.println();
}
keyBoard.close();
}
}
Comments
Leave a comment