In this project you will perform calculations with triangles

In this project, you will perform calculations with triangles. A triangle is defined by the x- and y-coordinates of its three corner points. Your job is to compute the following properties of a given triangle: the lengths of all sides the angles at all corners the perimeter the area Implement a Triangle class with appropriate methods. Supply a program that prompts a user for the corner point coordinates and produces a nicely formatted table of the triangle properties. A boat floats in a two-dimensional ocean. It has a position and a direction. It can move by a given distance in its current direction, and it can turn by a given angle. Provide methods public double getX() public double getY() public double getDirection() public void turn double degrees) public void move (double distance) The Cash Register class has an unfortunate limitation: It is closely tied to the coin system in the United States and Canada. Research the system used in most of Europe. Your goal is to produce a cash register that works with euros and cents. Rather than designing another limited cashRegister implementation for the European market, you should design a separate coin class and a cash register that can work with coins of all types.

Solution

// ------------------------------------------- Question 2 -------------------------------------

class Boat {
   private double x;
   private double y;
   private double direction;

   public Boat(double x, double y, double direction) {
       super();
       this.x = x;
       this.y = y;
       this.direction = direction;
   }

   public double getX() {
       return x;
   }

   public double getY() {
       return y;
   }

   public double getDirection() {
       return direction;
   }

   // considering ocean is a x-y map with center in the middle, with 360 deg.
   // freedom center of axis
   public void turn(double degrees) {
       this.direction = (this.direction + degrees) % 360;
   }

   // consider trignometry triangle
   public void move(double distance) {
       // cos d = x / direction;
       this.x += distance * Math.cos(Math.toRadians(this.direction));
       // sin d = y / direction;
       this.y += distance * Math.sin(Math.toRadians(this.direction));
   }
}

// ------------------------------------------- Question 3 -------------------------------------

class Coin {
   private int denomination;
   private String coinName;

   public Coin(int denomination, String coinName) {
       super();
       this.denomination = denomination;
       this.coinName = coinName;
   }

   public int getDenomination() {
       return denomination;
   }

   public void setDenomination(int denomination) {
       this.denomination = denomination;
   }

   public String getCoinName() {
       return coinName;
   }

   public void setCoinName(String coinName) {
       this.coinName = coinName;
   }

}

class CashRegister {
   private Coin coin;

   public CashRegister(Coin coin) {
       super();
       this.coin = coin;
   }

   public Coin getCoin() {
       return coin;
   }

   public void setCoin(Coin coin) {
       this.coin = coin;
   }
  
   //you can add other functionalities using the Coin object
}

 In this project, you will perform calculations with triangles. A triangle is defined by the x- and y-coordinates of its three corner points. Your job is to com
 In this project, you will perform calculations with triangles. A triangle is defined by the x- and y-coordinates of its three corner points. Your job is to com

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site