QUESTION DESCRIPTION 

Dhoni's daughter Ziva is hyper active child,so she used to ask lot of question to Dhoni while playing with him.

One fine evening Dhoni and Ziva were palying in Chepak Stadium in Chennai,at that time ziva looking at the Moon in sky asked Dhoni what is the gravity in moon? Dhoni said it's 16.6 percentage that of earth.

Ziva didn't got satisfied with that then she asked what will be my weight in moon?

Dhoni was little bit confused to answer ziva !!!!!

Can you help Dhoni to answer the question by creating a logic which calculates the weight of the person in moon so that Ziva will be happy knowing her weight.

Input Format:

Get the actual weight of the person

Output Format:

Print the weight in moon.

Refer Sample Testcases.

Programming Language need to be use:C++


```

#include <iostream>
using namespace std;
int main() {
  int weight;
  float moon;
  cin>>weight;
  moon=weight*16.6/100;
  cout<<"Your weight on moon is : "<<moon;
  

return 0;

}

```

Understanding the Problem: Calculating Weight on the Moon

Ziva's question about how much she would weigh on the Moon provides an excellent opportunity to explore basic physics concepts, specifically the effect of gravity on weight. Gravity is a fundamental force that varies depending on the celestial body you're on. Because the Moon's gravity is much weaker than Earth's, Ziva (or anyone) would weigh significantly less on the Moon. This concept leads us into an interesting calculation, and we can even take it a step further by developing a C++ program to automate these calculations.

In this article, we'll dive deep into the physics behind this problem, perform a step-by-step calculation for Ziva’s weight on the Moon, and explain how to implement this solution in C++ code. Let’s break it down into understandable terms, concepts, and actionable steps.

The Physics Behind Weight and Gravity

What Is Weight?

Weight is the force exerted on an object due to gravity. It is calculated by the formula:

Weight=Mass×Gravitational Acceleration (g)\text{Weight} = \text{Mass} \times \text{Gravitational Acceleration (g)}

On Earth, the gravitational acceleration is approximately 9.8m/s29.8 \, m/s^2. This means that for any object, its weight is its mass multiplied by 9.8. For example, a person with a mass of 70 kg will experience a weight force of 70kg×9.8m/s2=686Newtons70 \, \text{kg} \times 9.8 \, m/s^2 = 686 \, \text{Newtons}.

However, on the Moon, gravity is much weaker, about 16.6% of Earth's gravity. This lower gravity causes a corresponding decrease in weight, although the mass remains unchanged.

Gravity on the Moon

The force of gravity on the Moon is approximately 1/6th of Earth's gravity, or more precisely, 16.6%. This is why astronauts who walked on the Moon appeared to move more slowly and could jump higher than they could on Earth. While their mass stayed the same, their weight (the force pulling them down) was much lower.

To calculate a person's weight on the Moon, we can use the ratio of the Moon’s gravity to Earth’s gravity, which is 0.166. The formula to calculate the weight on the Moon is straightforward:

Weight on the Moon=Weight on Earth×0.166\text{Weight on the Moon} = \text{Weight on Earth} \times 0.166

This simple relationship allows us to calculate how much a person or object would weigh on the Moon based on their Earth weight.

Example Calculation: Ziva’s Weight on the Moon

Let’s assume that Ziva’s weight on Earth is 30 kg. To calculate her weight on the Moon, we multiply her Earth weight by the factor 0.166 (which represents the Moon's gravity as a percentage of Earth's gravity):

Weight on the Moon=30×0.166=4.98kg\text{Weight on the Moon} = 30 \times 0.166 = 4.98 \, \text{kg}

Therefore, Ziva would weigh approximately 4.98 kg on the Moon. It’s important to note that this is not her mass that has changed, but her weight due to the lower gravitational force on the Moon.

Why Does Weight Change, But Not Mass?

Mass is a measure of the amount of matter in an object, and it remains constant no matter where you are. Weight, on the other hand, is a force and depends on the gravitational field of the celestial body you're on. While Ziva's mass stays at 30 kg whether she’s on Earth, the Moon, or floating in space, her weight changes because of the differing strengths of gravitational pull.

The key takeaway is that mass is intrinsic to the object, while weight depends on the external force of gravity.

The Formula to Calculate Weight on the Moon

To summarize, the formula to calculate weight on the Moon from Earth weight is:

Weight on Moon=Weight on Earth×0.166\text{Weight on Moon} = \text{Weight on Earth} \times 0.166

This formula works for any object or person. Whether it’s Ziva, an astronaut, or a rock, the weight on the Moon will always be 16.6% of the weight on Earth. This is because gravity on the Moon is weaker, and objects will experience less force pulling them toward the Moon’s surface.

Now that we’ve covered the theoretical aspect, let's move on to programming this solution in C++.

Writing a C++ Program to Calculate Weight on the Moon

To make this calculation even easier, especially for people who want to avoid manual calculations, we can write a simple C++ program that automatically computes the weight on the Moon based on the user’s Earth weight.

Below is a simple C++ program that takes the user’s Earth weight as input, calculates their Moon weight using the formula we discussed, and prints the result.

C++ Code Example:

#include <iostream> using namespace std; int main() { // Declare variables double weightOnEarth, weightOnMoon; // Ask the user to enter their weight on Earth cout << "Enter your weight on Earth (in kg): "; cin >> weightOnEarth; // Calculate weight on the Moon weightOnMoon = weightOnEarth * 0.166; // Display the result cout << "Your weight on the Moon would be: " << weightOnMoon << " kg" << endl; return 0; }

Explanation of the Code:

  1. Input: The program starts by prompting the user to enter their weight on Earth. The cin function is used to capture this input and store it in the variable weightOnEarth.

  2. Calculation: The program then uses the formula we discussed earlier to calculate the weight on the Moon. The Earth weight is multiplied by 0.166, and the result is stored in the variable weightOnMoon.

  3. Output: Finally, the program prints the calculated Moon weight using cout, displaying the result to the user.

Running the Program

To run this program, you would need a C++ compiler (like GCC or any IDE that supports C++ such as Code::Blocks or Visual Studio). After compiling and running the program, the user will be asked to input their Earth weight, and the program will return the corresponding weight on the Moon.

Sample Output:

Enter your weight on Earth (in kg): 70
Your weight on the Moon would be: 11.62 kg

This C++ program can handle any weight input and will always provide the accurate Moon weight, thanks to the simple yet effective formula.

Why Use a Program for This?

While the formula itself is simple, using a program offers several advantages:

  • Convenience: Instead of performing the calculation manually, users can quickly get results by inputting their Earth weight.
  • Accuracy: There’s no risk of making calculation errors when using a program. The program will always multiply the Earth weight by exactly 0.166.
  • Automation: This C++ program can be expanded to handle multiple inputs, calculate the weight on other celestial bodies, or even factor in more complex scenarios like varying altitudes or gravitational fields on different parts of the Moon.

Expanding the Program: Weight on Other Celestial Bodies

One interesting extension of this program is to calculate a person's weight on other planets or celestial bodies like Mars, Jupiter, or even in space. The process would be similar, except the gravity factor would change depending on the body being considered.

For example, to calculate the weight on Mars, where gravity is about 38% of Earth's, you would modify the formula to:

Weight on Mars=Weight on Earth×0.38\text{Weight on Mars} = \text{Weight on Earth} \times 0.38

The program could be adapted to allow the user to choose different planets or moons, providing a more comprehensive view of how gravity affects weight throughout the solar system.

Sample Expansion for Multiple Planets


#include <iostream> using namespace std; int main() { double weightOnEarth, weightOnMoon, weightOnMars; cout << "Enter your weight on Earth (in kg): "; cin >> weightOnEarth; weightOnMoon = weightOnEarth * 0.166; weightOnMars = weightOnEarth * 0.38; cout << "Your weight on the Moon would be: " << weightOnMoon << " kg" << endl; cout << "Your weight on Mars would be: " << weightOnMars << " kg" << endl; return 0; }

This code now allows users to calculate their weight on both the Moon and Mars.

Conclusion

Understanding how gravity affects weight is a fundamental concept in physics, and Ziva's question opens the door to exploring this idea. The gravity on the Moon is much weaker than Earth's, making objects weigh significantly less. By using the formula:

Weight on Moon=Weight on Earth×0.166\text{Weight on Moon} = \text{Weight on Earth} \times 0.166

we can easily calculate how much someone would weigh on the Moon. Additionally, using a simple C++ program to automate this calculation makes it even easier and ensures accuracy.

This exploration into weight and gravity is not only a great way to understand basic physics but also a fun way to think about space travel and how humans would experience different celestial bodies.