Sale!

COP 3223C Homework 1 solved

Original price was: $30.00.Current price is: $25.00. $21.25

Category:

Description

5/5 - (1 vote)

Basic computation and input/output

You are an amateur astronomer and space travel buff and dream about someday visiting other planets
in the Solar System.

The recent discovery of the planet Proxima b about four light‐years away (practically
next door in intergalactic terms), which appears to be a rocky planet with an atmosphere that could
support life as we know it, has given you a new urge to do something.

So, you decide to write a
computer program in C that will let a user learn a little about each planet (very little!). The program is to
calculate the surface area of each of the planets in the Solar System and its distance from the Sun. The
program will include the nine planets in the Solar System, including the recently demoted Pluto.

So:
Write a program that requests from the user the name of the planet in the Solar System about which
the user wants to learn more. Because you don’t yet know about strings in C, you can input the first
letter of each planet’s name: m for Mercury; v for Venus; e for Earth; a for Mars (m is already taken!); j
for Jupiter; s for Saturn; u for Uranus; n for Neptune; and p for Pluto.

The program will print out the
surface area (look up the formula!) of the requested planet (assume they are prefect spheres) in square
miles (not kilometers!), and its distance from the Sun, also in miles.

The planetary data can be found in http://nssdc.gsfc.nasa.gov/planetary/factsheet/. The important
pieces of information in that webpage are the circumference of each planet and its distance from the
Sun. Note that these values are in Km, so you will have to convert to miles. You can find the conversion
factor also from the Web.

Make the output friendly. It should state the output as follows:
Welcome to the program Learning about Planets!
You have selected to learn about
The surface area of is

square miles.
is miles away from the Sun
There are several requirements (“musts”) in this assignment:
1. Your program must calculate the surface area of the planet knowing only the diameter, and it must
convert the distance from Km to miles. You should look up the formula for the surface area of a
sphere and the Km‐to‐miles conversion factor, but NOT the final numbers to be printed out

2. Your program must use preprocessor directives (#define) to hold the values of the circumference
and distance from the Sun for each of the planets.

3. Your program must also use a selection structure to decide which planet the program is to address.
A multiple selection structure (if/elseif/…/else) or (preferably) a switch structure would
be required.

4. Your program must use scanf() to obtain the user’s choice for the planet to be treated.
5. Lastly (and obviously!), your program must be written in C and must compile and execute correctly
from Code::Blocks
COP 3223C Homework 1

Submission Instructions

The assignment is due at 3:00 PM sharp on the day indicated in the “Due Date” line of the
assignment header at the top of this document. Canvas will label any assignment turned in late
as “late”; those so labeled can only aspire to 50% of the value of the assignment. Note that
“barely late” is not a possible label.

Assignments should be submitted via the class site on Canvas as a file. The only thing to be
submitted is the source code file, which should be named: HW1 ‐ .c. There is
no need for a cover letter or project report of any kind. Just the source file!

Teaching assistants will download the source file you submitted through the Canvas site, load it
into Code::Blocks, compile it and execute it.

They will then check to ensure all of the
requirements (the musts) have been satisfied. They will put a grade right into your Canvas
grade section.

COP 3223C Homework 1