Write a program to display all possible firing solution

Assignment Help JAVA Programming
Reference no: EM132348732

Programming Assignment -

Background - The belligerent country of Kablamistan has launched an inter-continental ballistic missile towards a country 10000km away which threatens to destroy the peaceful Goners who live there.

Fortunately the United Nations has anticipated this possibility and out of concern for the citizens of Goneria has placed a high-powered laser at the midpoint between the site of the missile's launch (Launchtown, Kablamistan) and the target (Doomsville, Goneria). The laser is capable of destroying the missile in mid-air.

Unfortunately the laser's guidance system got fried when the soldier monitoring the system blew its fuse when trying to cook a pop-tart with the laser and no replacement component could be found. Given the military's well known policy of awarding contracts to the lowest bidder, you've been given the job of developing software to upload into the 80286 computer that will be used to drive the laser!

The diagram below illustrates the situation.

2047_figure.png

The technical specifications are as follows:

The missile

  • is fired at Doomsville at 12:30PM, i.e. at lunchtime in Launchtown!
  • flies an elliptical path (with a major radius of 5000km and a minor radius of 50km) which is 15709km long.
  • travels each of the 180 x 1° segments in which it can be targeted by the laser in 43.635s; and

The laser

  • is 5000km between Launchtown and Doomsville directly below the path of the missile;
  • requires 65s to charge before it may be fired;
  • moves in 1° increments - where 0° is along the ground to Launchtown, 90o is straight up, and 180o is along the ground to Doomsville;
  • requires 35s to move 1o (and starts perpendicular to the ground, i.e. at 90o);
  • should only be fired at degrees in the range 1-179o;
  • may move while being charged; and
  • fires instantly for an infinite distance destroying anything in its path.

Given an angle t in the range of 0-180o for the direction of the laser, the position of the missile on its elliptical path is the coordinate (x, y) where x = 5000*Math.cos(r) and y=50*Math.sin(r). r is the value t converted to radians and the conversion can be done with a built-in method: r=Math.toRadians(t);

If the missile will be at this coordinate at the time the laser is aiming there then this is a firing solution. Firing solutions consist of:

  • the time the laser should be fired;
  • the degree at which the laser should be aimed; and
  • the resulting coordinate at which impact with the missile would occur.

Program specification - You and your partner must write a Java program to calculate and display all possible firing solutions. Firing solutions should be determined in order (from the greatest distance from Doomsville to the least distance from Doomsville).

Your solution should run in Dr Java and comprise the following files:

- TimeInterface.java and Time.java - the Time ADT as used in lectures and tutorials, and extended with a method to add seconds to an existing time. The heading for this additional function should be: void addSeconds(double s);

Only the whole number portion of the double value should be added to the time object;

- FiringSolutionInterface.java and FiringSolution.java - the specification and implementation (respectively) of a firing solution. A firing solution should be implemented as a class with instance variables which consist of:

  • the time the laser should be fired (as a Time value);
  • the degree at which the laser should be aimed (as an int); and
  • the resulting coordinate at which impact with the missile would occur (as two double fields, x and y).

and the operations should include a getter and setter for each field.

- AssigOne219.java - the file which contains the main() method and other functions which implement the required task.

A starting point is available on MyLO for you to download. You should complete all of the required files. You may need nextLine() and nextInt() from java.util.Scanner, print() and println() from java.lang.System, compareTo() and charAt() from java.lang.String, valueOf() from java.lang.Integer, and format() from java.text.DecimalFormat. You will also need to use if and if-else statements, and for and while loops.

Algorithm - AssigOne219.java should implement the following algorithm:

setting up the launch time

iterating through each position (degree) of the missile from Launchtown to Doomsville and for each

iterating through the following steps until a solution is found or it is determined there are no solutions

calculating how the laser would need to move to get there

calculating how the missile would need to move to get there

determining how many seconds the movement of each item would take and, if the laser can get there no later than the missile

  • determine the (x,y) coordinate of impact and the time
  • create a firing solution of these values
  • display the time and firing solution (you can make use of the defined DecimalFormat objects to format the output of Time and FiringSolution objects)

otherwise

  • moving the missile to the next location (degree)

Program Style - Your program should follow the following coding conventions:

  • final variable identifiers should be used as much as possible, should be written all in upper case and should be declared before all other variables
  • variable identifiers should start with a lower case letter
  • every if and if-else statement should have a block of code (i.e. collections of lines surrounded by { and }) for both the if part and the else part (if used)
  • every do, for, and while loop should have a block of code (i.e. {}s)
  • the keyword continue should not be used
  • the keyword break should only be used as part of a switch statement
  • opening and closing braces of a block should be aligned
  • all code within a block should be aligned and indented 1 tab stop (or 4 spaces) from the braces marking this block
  • instance variables should be used sparingly with parameter lists used to pass information in and out of functions
  • local variables (excluding loop counters) should only be declared at the beginning of methods (either as parameters or otherwise)

Note - There should be a block of header comment which includes at least - file name, student names, student identity numbers, a statement of the purpose of the program, date, the percentage of the work completed by the authors - 50:50 is expected and assumed but reasons should be given if it is more/less than this and Each variable declaration should be on a single line and should be commented. There should be comments that identify groups of statements that do various parts of the task. Comments should describe the strategy of the code and should not simply translate the Java into English.

Attachment:- Programming Assignment Files.rar

Reference no: EM132348732

Questions Cloud

What is portfolio return : If your portfolio is made up of 40% Conglomco stock, 30% Supercorp stock, and 30% Megaorg stock, what is your portfolio return.
Operating and maintenance costs of a capital project : Discuss two to three (2-3) actions an administrator should review consistently to alleviate over budgeting for operating and maintenance costs of a capital
Conglomco stock ended last year : Conglomco stock ended last year at $77.24. If you owned 200 shares of Conglomc stock, what were your dollar return and percent last year?
Company required rate of return on equity : 1. Suppose you have a firm with the following information (ignore financial distress costs):
Write a program to display all possible firing solution : KIT107 Programming Assignment, University of Tasmania, Australia. Write a Java program to calculate and display all possible firing solutions
Identify factors that influence policy drivers : F/504/2218-Understand professional management and leadership in health and social care or children and young people’s settings.Research theories of management.
What kind of option position did the insurance companies : What kind of option position did the insurance companies have? (Long or Short? European or American? Put or Call?) Explain your answer.
Credit card a charges an annual effective interest rate : Credit Card A charges an annual effective interest rate of 21.56% and a $100 annual fee. If your average outstanding balance is $2,000
What is the npv of opening the bakery : If your discount rate is 14.00%, what is the NPV of opening the bakery?

Reviews

len2348732

7/30/2019 3:52:24 AM

This assignment is to be completed in pairs. You and your partner should work together on all of the design and programming. It should be done using the pair-programming methodology and not by division of labour. Use the “Assignment 1 Pairs” groups on MyLO to find and register your pair.

len2348732

7/30/2019 3:52:16 AM

What to submit - Paper submission: A signed paper cover page (blanks can be collected from the Information and Communications Technology Discipline office or from the ICT web site). A landscape oriented print-out of the completed files for the program. Your assignment will not be fully marked unless these are present. One effective way to grasp principles and concepts is to discuss the issues with your peers and/or friends. You are encouraged to do this. We also encourage you to discuss aspects of practical assignments with others. However, once you have clarified the principles of the question, you must develop and express the solution in writing or electronically entirely by yourself in your pair. In other words you and your partner must develop the algorithm to solve the problem and write the program which implements this algorithm yourselves. You can discuss the question, but not the solution.

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd