Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main{
- public static void main(String[] args) {
- Molecule[] m = new Molecule[10];
- int i = 0;
- while (true){
- m[i] = new Molecule();
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter structure : ");
- m[i].structure = sc.nextLine();
- if (m[i].structure.equals("0")) break;
- System.out.println("Enter name : ");
- m[i].name = sc.nextLine();
- System.out.println("Enter weight : ");
- m[i].weight = sc.nextDouble();
- i++;
- }
- for (int j = 0; j < i; j++ ){
- m[j].display();
- }
- }
- }
Add Comment
Please, Sign In to add comment