Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2B (50 points + 5 bonus) Programing in C not C++ Implement a program that inputs the diameter of a planet and the area

Problem 2B (50 points + 5 bonus) Programing in C not C++

Implement a program that inputs the diameter of a planet and the area covered by water, and determines whether the planet is suitable for human settlements; and, if not, whether it is suitable for a research station. Unlike a simpler version in Problem 2A, it should allow inputting information about multiple planets, print the results for each planet, and count the number of planets.

A planet is suitable for settlements if it satisfies the following criteria: Its diameter is between 95% and 105% of the Earth diameter. The percentage of surface covered by water is between 10% and 90%. When a planet is not suitable for settlements, it is suitable for a research station if it satisfies the following criteria: Its diameter is no greater than 150% of the Earth diameter. The percentage of surface covered by water is no greater than 99%. The crew members measure the diameter of the planet (planet-diameter) and the area covered by water (water-area). Then, they calculate the values needed for their analysis: diameter-percentage = (planet-diameter / earth-diameter) 100% total-area = planet-diameter planet-diameter water-percentage = (water-area / total-area) 100% They use the following two constants in the calculations:= 3.14159 earth-diameter = 7,918 (miles)

Input and output:

Your program should prompt the user to enter the diameter of the planet and the area covered by water. We assume that the diameter is a real value between 100.0 and 100,000.0 (measured in miles), and the area covered by water is a real value between 0.0 and 30,000,000,000.0 (measured in square miles). The program should then print one of these three statements: The planet is suitable for settlements, The planet is suitable for a research station, or The planet is not suitable for humans. After the program inputs the information about the first planet and outputs the related sentence, it should prompt the user to input information about the second planet, then about the third planet, and so on. When there are no more planets, the user inputs a negative number (e.g. ?1) as the planets diameter, which is the termination signal. Once the program gets a negative diameter, it should print the total number of planets and stop.

image text in transcribed

Example: Command Prompt Enter diameter of the planet: 8000.0 Enter area covered by water: 100000000.0 The planet is suitable for settlements Enter dianeter of the planet: 1000 Enter area covered by water:0 The planet is suitale for a research station Enter diameter of the planet: 20000 Enter area covered by water: 100000000 The planet is not suitable for hunans Enter dianeter of the planet: 1 The Enterprise has discovered 3 new planets

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago