Problem 2B (50 points + 5 bonus) Programing in C not C++ Implement a program tha
ID: 3725695 • Letter: P
Question
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.
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 planet’s diameter, which is the termination signal. Once the program gets a negative diameter, it should print the total number of planets and stop.
OUTPUT
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 planetsExplanation / Answer
Hi Friend, YOu have not mention the condition for "settlement" and "research station". SO i have written template program. Please fill condition in IF and ELSE IF condition.
#include <stdio.h>
int main() {
float diameter = 0, area = 0;
int count = 0;
while(1) {
printf("Enter diameter of the planet: ");
scanf("%f", &diameter);
if(diameter < 0)
break;
count++;
printf("Enter area covered by water: ");
scanf("%f", &area);
if(){ // condition for settlement
printf("The planet is suitable for settlement ");
}
else if() {// condition for research station
printf("The planet is suitable for settlement ");
}else{ //
printf("The planet is not suitable for human ");
}
}
printf("The Enterprise discovered %d new planets ", count);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.