Please check the report summary example below & provide the application source code, console output and the report file:
Place the following parallel arrays as globals in your program class (before the main() ).
static String[]
planetname
={"Earth","Mercury","Jupiter","Mars","Saturn","Uranus","Neptune","Pluto","Venus", };
// diameter in kilometres : static int[]
diamKM
={ 12760, 4878, 139822, 6787,120500, 51120, 49530, 2301, 12104, };
// orbit time (in Earth years) : static double[]
orbYR
={ 0.241, 0.616, 1.0, 1.88, 11.9, 29.5, 84.0, 165.0, 248.0 };
In the main(),
Step 1: convert from orbit in years to orbit in days,
1. declare a new int array
orbDays[ ]
using the length of
orbYR[ ]
array
2. populate the new array with the values of the
orbYR[ ]
array converted to days,
- orbit in days = (orbit in years * 365)
Step 2: use the orbDays[ ] array and planetname[ ] (name) array,
1. planet with minimum orbit, determine: minOrb and nameMinOrb
2. planet with maximum orbit, determine: maxOrb and nameMaxOrb
Step 3: using the outcomes from the above, generate a summary report (send to a report file)
1. display the orbit in days; ex: Venus orbit is 224 days, Earth orbit is 365 days
2. planet name is shown in UPPERCASE
3. diameter is shown in x/1000’s of kms in format 4.2f (2 decimal places); ex: Mercury’s diam (4878 kms) is 4.88
4. the report is displayed on the console, and sent to a file (planetreport.txt)
5. use a common output string, which contains the output, to easily send to console and report file
6. use Exam.writeStringToFile("planets.txt") to send the report to the file.
This is how the summary report should look:
The summary report format:
Planet Diam(1000kms) Orbit(days)
-----------------------------------------------------------
EARTH 12.77 365
MERCURY 4.88 87 .
.
. VENUS 12.10 224
-----------------------------------------------------------
Min. orbit: 87 days Mercury
Max. orbit: 90520 days Pluto