moonelite99

Main of Molecule

Feb 18th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main{
  4.     public static void main(String[] args) {
  5.         Molecule[] m = new Molecule[10];  
  6.         int i = 0;        
  7.             while (true){
  8.                 m[i] = new Molecule();
  9.                 Scanner sc = new Scanner(System.in);
  10.                 System.out.println("Enter structure : ");
  11.                 m[i].structure = sc.nextLine();
  12.                  if (m[i].structure.equals("0")) break;
  13.                 System.out.println("Enter name : ");
  14.                 m[i].name = sc.nextLine();
  15.                 System.out.println("Enter weight : ");
  16.                 m[i].weight = sc.nextDouble();
  17.                 i++;
  18.             }
  19.             for (int j = 0; j < i; j++ ){
  20.                 m[j].display();
  21.             }          
  22.         }  
  23. }
Add Comment
Please, Sign In to add comment