Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions 6-methods/31-earths-moon.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@

public class HelloWorld {

public static double earthMoonWeight(String name, int weight, String unit) {
public static void earthMoonWeight(String name, int weight, String unit){

double moonWeight = weight * (1.62 / 9.81);
return moonWeight;
double weightOnMoon = weight * (1.62 / 9.81);
String message = "Hi " + name + "! Your weight on Earth is " + weight + " and your weight on the moon would be about " + weightOnMoon + unit +". ";
System.out.println(message);

}

public static void main(String[] args) {

String name = "Max";
int earthWeight = 30;
String unit = "lbs";
double moonWeight = earthMoonWeight(name, earthWeight, unit);

System.out.println("Hi " + name + "! Your weight on Earth is " + earthWeight + unit +
" and your weight on the moon would be about " + moonWeight + unit + ".");
earthMoonWeight("Max",30,"lbs");
}
}