Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Products {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int cntr = 0;
- String[] name = new String[100];
- String[] idNo = new String[100];
- double[] profit = new double[100];
- System.out.print("Enter number of items: ");
- int number = scan.nextInt();
- System.out.println("");
- for (int i = 0; i < number; i++) {
- System.out.println("Enter data of item " + (i+1) + ":");
- System.out.print("ID: ");
- String id = scan.nextLine();
- scan.nextLine();
- System.out.print("Name: ");
- String ProdName = scan.nextLine();
- System.out.print("Quantity: ");
- int quantity = scan.nextInt();
- System.out.print("Price: ");
- int price = scan.nextInt();
- System.out.println(" ");
- int multipy = quantity * price;
- idNo[i] = id;
- name[i] = ProdName;
- profit[i] = multipy;
- }
- System.out.println("------------------------------------------------ ");
- System.out.println("Summary of items");
- System.out.println("------------------------------------------------ ");
- System.out.println("No." + "ID" + "Names" + " " + "Expected Profit");
- for(int i=0; i<100; i++){
- System.out.println((i+1) + " " + idNo[i] + " " + name[i] + " " + profit[i]);
- cntr++;
- if(cntr == number){
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement