Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Start with Crater. When you look at the provided Java below , you'll see the original BASIC code shown as comments. Most of the program

Start with Crater. When you look at the provided Java below , you'll see the original BASIC code shown as comments. Most of the program is formulas. Now you don't have to understand those formulas (unless you really want to!). I don't. But you do need to find equivalent Java math functions to use and basically create one line of Java for each original line of BASIC. I give some hints for how this will work. This is really a warm-up for Rainbow, coming up next. You can just create a new class Crater, and paste the code from crater_start.java into Eclipse.

Once your program compiles, try running it. It prompts for some quantities (mass of the impactor, etc.) Try the values I used (below) and see if you get the same results. (Either or both of us could be wrong, of course). Then try some different values and post your inputs and outputs in the provided Blackboard forum. Try someone else's values and see if you get their same result. When we get to the point that we're getting consistent answers, we can be reasonably certain that our translations are correct.

import java.util.Scanner; /* 10 REM - IMPACT CRATER DIMENSIONS 20 CLS : PI=3.14159 30 CR1=18: CD1=9 40 PRINT "Terrestrial Impact Crater" 50 INPUT " Impactor diameter (m)";ID 60 INPUT " Impactor density (kg/m^3)";IR 70 INPUT " Impactor velocity (km/s)";IK 80 INPUT " Graze angle (deg. from horiz.)";GA 90 IV=IK*1000: VI=PI*ID*ID*ID/6 100 GF=(SIN(GA/180*PI))^.33 110 MI=IR*VI: KE=.5*MI*IV*IV 120 KT=KE/4.2E+12: REM impactor KE in kT TNT 130 PRINT: PRINT "Impactor Parameters" 140 PRINT USING " Volume ##.##^^^^ m^3"; VI 150 PRINT USING " Mass ##.##^^^^ kg"; MI 160 PRINT USING " KE ##.##^^^^ J"; KE 170 PRINT USING " ##.##^^^^ kT TNT"; KT 180 CD=2*CR1*KT^.3*GF: CA=CD*1.25 190 CZ=CD1*KT^.3*GF: CL=CZ*1.25 200 CV=.5*PI*CD*CD/4*CZ 210 CE=2.15*CD 220 PRINT: PRINT "Crater Parameters" 230 PRINT " Diameter --" 240 PRINT USING " Actual ###### m"; CD 250 PRINT USING " Apparent ###### m"; CA 260 PRINT " Depth --" 270 PRINT USING " Actual ##### m"; CZ 280 PRINT USING " Apparent ##### m"; CL 290 PRINT USING " Target removed ##.##^^^^ m^3"; CV 300 PRINT USING " Ejecta spread ###### m"; CE 310 REM ======================== 320 REM FROM "ASTRONOMICAL 330 REM COMPUTING," SKY & TELE- 340 REM SCOPE, NOVEMBER 1996 350 REM ======================== 360 END */ // check against: // http://www.convertalot.com/asteroid_impact_calculator.html public class Crater { public static void main(String[] args) { /* Your translation of the above BASIC to Java goes here. */ /* Notes: PRINT becomes system.out.println ( ) ; PRINT USING is formatted output, you can likely ignore the formatting REM is a comment INPUT is a combination of System.out.println ( prompt) then use a Scanner to getNext ( ) the needed value. ^ means exponentiation, or "raising to a power" : allows multiple BASIC statements on the same line. */ } }

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions