Advertisement
Guest User

na

a guest
Oct 12th, 2023
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | Source Code | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class KeplerLabFinal {
  4.  
  5.     public KeplerLabFinal(String name, double mass, double semiMajorAxis){
  6.         this.getPlanetName = name;
  7.         this.getPlanetMass = mass;
  8.         this.getSemiMajorAxis = semiMajorAxis;
  9.     }
  10.  
  11.     public static void main(String[] args){
  12.         ArrayList<KeplerLabFinal> planets = new ArrayList<>();
  13.         planets.add(new KeplerLabFinal("Mercury", 3.285e23, 0.38710));
  14.         planets.add(new KeplerLabFinal("Venus", 4.867e24, 0.72333));
  15.         planets.add(new KeplerLabFinal("Earth", 5.972e24, 1));
  16.         planets.add(new KeplerLabFinal("Mars", 6.39e23, 1.52366));
  17.         planets.add(new KeplerLabFinal("Jupiter", 1.898e27, 5.20336));
  18.         planets.add(new KeplerLabFinal("Saturn", 5.683e26, 9.53707));
  19.         planets.add(new KeplerLabFinal("Uranus", 8.681e25, 19.1913));
  20.         planets.add(new KeplerLabFinal("Neptune", 1.024e26, 30.0690));
  21.         planets.add(new KeplerLabFinal("Pluto", 1.309e22, 39.4821));
  22.  
  23.  
  24.         for(KeplerLabFinal planet : planets){
  25.             if(planet.getSemiMajorAxis >= 2 && planet.getSemiMajorAxis <= 15){
  26.                 System.out.println(planet.getPlanetName);
  27.             }
  28.         }
  29.     }
  30. }
  31.  
Tags: Java
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement