Questions
For today's lab we will be using the Car Object Class which we built in Lab...

For today's lab we will be using the Car Object Class which we built in Lab 1. I have attached my solution if you would prefer to use my solution instead of your own solution.

We will working on remembering how to build sub-classes and user interfaces. So we will be creating new Java files for:

  • An Interface called GreenHouseGasser
    • Requires a method called CO2() which returns how much carbon dioxide the Object produces.
    • Make sure to update Car so that Car implements GreenHouseGasser. Cars should produce 1.5 units of CO2 for every mph the car is traveling.
  • A Car sub-class called SportsCar:
    • Overrides the accelerate() method. SportsCars accelerate twice as fast as regular Cars
    • Overrides the CO2() method. SportsCars should be using a factor of 3.25 units of CO2 for every mph
  • A Car sub-class called EcoCar
    • Overrides the accelerate() method. EcoCars accelerate 25% as fast as regular Cars
    • Overrides the CO2() method. EcoCars should be using a factor of .33 units of CO2 for every mph

As your are building/updating your objects, remember to test. You'll need update the Driver to test your new methods and Objects!

Submit all of your .java files in one jar or zip file.

Grading Breakdown:

  • Driver tests all new methods and objects -- 25%
  • Interface created correctly and Car updated to implement the Interface -- 25%
  • SportsCar correctly created -- 20%
  • EcoCar correctly created -- 20%
  • JavaDoc comments! -- 10%

Here is the Car Object pre-made:

public class Car
{
private String name;
private int currentSpeed;
  
public Car(String inName)
{
name = inName;
}
  
public void accelerate()
{
currentSpeed += 10;
}
  
public void park()
{
currentSpeed = 0;
}
  
public void printCurrentSpeed()
{
System.out.println("Current Speed is: " + currentSpeed);
}
}

Here is the driver that is supposed to be used:

public class Driver {
  
   public static void main(String[] args) {
       // create new Audi car
       Car audi = new Car("Audi");
       // create new Nissan car
       Car nissan = new Car("Nissan");
      
       // print current speed of Audi - it is 0
       audi.printCurrentSpeed();
      
       // call the accelerate method twice on Audi
       audi.accelerate();
       audi.accelerate();
      
       // call the accelerate method once on Nissan
       nissan.accelerate();
      
       // print current speed of Audi - it is now 20 mpH
       audi.printCurrentSpeed();
       // print current speed of Nissan - it is 10 mpH
       nissan.printCurrentSpeed();
      
       // now park the Audi car
       audi.park();
      
       // print current speed of Audi - it is now 0, because the car is parked
       audi.printCurrentSpeed();
   }
}

In: Computer Science

You are riding your bicycle directly away from a stationary source of sound and hear a...

You are riding your bicycle directly away from a stationary source of sound and hear a frequency that is 0.7% lower than the emitted frequency. The speed of sound is 346 m/s. What is your speed?

In: Physics

Use the data and develop 95% and 99% prediction intervals for the following A. the hours...

Use the data and develop 95% and 99% prediction intervals for the following
A. the hours per week that an individual will spend in his vehicle
B. the number of miles driven per week
Vehicle Driven Type Satisfaction with vehicle Gender Age # of hours per week in vehicle Miles driven per week Number of Children Average number of riders Miles from work
Truck Domestic Yes Male 31 10 450 0 1 30
Truck Domestic Yes Male 29 5 370 1 1 22
Truck Foreign No Male 26 12 580 0 1 15
Truck Domestic No Male 18 6 300 0 1 20
SUV Domestic Yes Male 49 21 1000 0 1 22
SUV Foreign Yes Male 50 16 840 2 1 45
SUV Domestic Yes Male 48 15 1400 3 4 25
SUV Foreign Yes Male 45 5 300 2 2 20
SUV Domestic Yes Male 45 15 850 0 1 25
SUV Domestic Yes Male 44 10 700 2 1 40
SUV Foreign Yes Male 41 5 350 1 1 20
SUV Domestic Yes Male 41 30 1500 4 3 15
SUV Foreign No Female 39 6 280 1 1 17
SUV Foreign Yes Female 36 4 400 0 1 20
SUV Foreign Yes Female 33 3 420 0 1 25
SUV Domestic Yes Male 31 10 675 0 1 35
SUV Domestic No Female 31 15 800 1 1 50
SUV Domestic No Female 29 4 300 1 1 20
SUV Domestic Yes Male 28 3 400 1 1 15
Mini Van Domestic Yes Female 55 8 400 0 2 0
Mini Van Domestic No Female 43 10 700 2 3 0
Mini Van Domestic Yes Female 41 10 720 1 2 15
Mini Van Foreign Yes Female 38 10 450 4 5 0
Mini Van Foreign Yes Female 39 15 1000 1 2 0
Mini Van Domestic No Male 35 5 350 2 2 0
Mini Van Domestic Yes Female 33 10 800 2 3 0
Mini Van Foreign Yes Female 32 2 200 4 5 5
Mini Van Foreign Yes Female 28 8 350 3 4 0
Car Domestic Yes Female 21 4 150 0 1 0
Car Domestic No Female 62 5 175 0 2 0
Car Domestic Yes Female 61 5 355 0 1 15
Car Foreign Yes Male 60 5 150 0 1 10
Car Domestic No Male 58 10 600 0 1 35
Car Domestic Yes Female 51 11 600 0 1 40
Car Domestic Yes Female 47 4 300 0 1 21
Car Domestic No Male 46 4 275 0 1 18
Car Domestic No Male 44 6 285 2 3 16
Car Foreign No Female 42 5 400 2 3 22
Car Foreign Yes Female 41 5 350 2 2 23
Car Domestic No Female 41 10 600 1 2 34
Car Domestic Yes Female 39 10 700 1 2 45
Car Foreign Yes Female 34 10 600 1 2 16
Car Foreign Yes Male 33 5 400 1 2 22
Car Foreign Yes Male 30 5 350 1 2 18
Car Domestic Yes Female 29 5 250 0 1 19
Car Foreign Yes Female 27 6 355 0 2 23
Car Foreign Yes Female 26 5 175 0 1 11
Car Domestic No Female 24 5 300 0 1 4
Car Domestic Yes Female 22 5 350 0 1 3
Car Foreign No Female 19 5 500 0 2 4

In: Statistics and Probability

mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 21 6 160...

mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21 6 160 110 3.9 2.62 16.46 0 Manual 4 4
Mazda RX4 Wag 21 6 160 110 3.9 2.875 17.02 0 Manual 4 4
Datsun 710 22.8 4 108 93 3.85 2.32 18.61 1 Manual 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 Automatic 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.44 17.02 0 Automatic 3 2
Valiant 18.1 6 225 105 2.76 3.46 20.22 1 Automatic 3 1
Duster 360 14.3 8 360 245 3.21 3.57 15.84 0 Automatic 3 4
Merc 240D 24.4 4 146.7 62 3.69 3.19 20 1 Automatic 4 2
Merc 230 22.8 4 140.8 95 3.92 3.15 22.9 1 Automatic 4 2
Merc 280 19.2 6 167.6 123 3.92 3.44 18.3 1 Automatic 4 4
Merc 280C 17.8 6 167.6 123 3.92 3.44 18.9 1 Automatic 4 4
Merc 450SE 16.4 8 275.8 180 3.07 4.07 17.4 0 Automatic 3 3
Merc 450SL 17.3 8 275.8 180 3.07 3.73 17.6 0 Automatic 3 3
Merc 450SLC 15.2 8 275.8 180 3.07 3.78 18 0 Automatic 3 3
Cadillac Fleetwood 10.4 8 472 205 2.93 5.25 17.98 0 Automatic 3 4
Lincoln Continental 10.4 8 460 215 3 5.424 17.82 0 Automatic 3 4
Chrysler Imperial 14.7 8 440 230 3.23 5.345 17.42 0 Automatic 3 4
Fiat 128 32.4 4 78.7 66 4.08 2.2 19.47 1 Manual 4 1
Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 Manual 4 2
Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.9 1 Manual 4 1
Toyota Corona 21.5 4 120.1 97 3.7 2.465 20.01 1 Automatic 3 1
Dodge Challenger 15.5 8 318 150 2.76 3.52 16.87 0 Automatic 3 2
AMC Javelin 15.2 8 304 150 3.15 3.435 17.3 0 Automatic 3 2
Camaro Z28 13.3 8 350 245 3.73 3.84 15.41 0 Automatic 3 4
Pontiac Firebird 19.2 8 400 175 3.08 3.845 17.05 0 Automatic 3 2
Fiat X1-9 27.3 4 79 66 4.08 1.935 18.9 1 Manual 4 1
Porsche 914-2 26 4 120.3 91 4.43 2.14 16.7 0 Manual 5 2
Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.9 1 Manual 5 2
Ford Pantera L 15.8 8 351 264 4.22 3.17 14.5 0 Manual 5 4
Ferrari Dino 19.7 6 145 175 3.62 2.77 15.5 0 Manual 5 6
Maserati Bora 15 8 301 335 3.54 3.57 14.6 0 Manual 5 8
Volvo 142E 21.4 4 121 109 4.11 2.78 18.6 1 Manual 4 2

Using the Motor Trend Cars Data Set, you would like to determine if there is a relationship between MPG (miles per gallon) and specific variables included in the data set.

  1. Develop a correlation matrix using MPG (miles per gallon), HP (horsepower), WT (weight). Is the correlation between the variables MPG v HP significant? Perform the appropriate test and use a level of significance of 0.05
  2. Fit a multiple regression model using MPG (miles per gallon) as the dependent variable and HP (horsepower), and WT (weight) as the independent variables. State your regression model.
  3. Is the overall regression model significant? Conduct the appropriate hypothesis test for the significance of the overall regression model. Use a 0.05 level of significance.
  4. Are the individual independent variables significant? Conduct the hypothesis tests for the significance of each independent variable at the= 0.05 level of significance.
  5. What proportion of the variation in MPG is explained by the independent variables HP and WT?
  6. Graph the residuals from the regression you developed in part (a). Do the regression assumptions appear to be appropriate given the residual plots? Explain your answer.

In: Statistics and Probability

I am using IntelliJ IDEA with JavaFX to build a travel expensive calculator, but somehow it...

I am using IntelliJ IDEA with JavaFX to build a travel expensive calculator, but somehow it 

wouldn't calculate total expensive? It was working until I add the TextFieldListener because I need to make sure user

only input either mile driven or airfareCost. Please help me figure out what I did wrong.

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class Main extends Application {

    TextField field1, field2, field3, field4, field5, field6;
    Button submitButton, cancelButton;

    @Override
    public void start(Stage primaryStage) throws Exception{

        Label label1 = new Label ("(1) Number of days on the trip");
        Label label2 = new Label ("(2) Transportation cost (choose one only)");
        Label label3 = new Label ("Airfare Cost ");
        Label label4 = new Label ("Miles driven  ");
        Label label5 = new Label ("(3) Conference registration cost ");
        Label label6 = new Label ("(4) Lodging Cost (per night) ");
        Label label7 = new Label ("(5) Food cost (total) ");
        Label TotalExpensive = new Label("Total expenses: ");
        Label TotalExpensiveResult = new Label(" ");
        Label TotalCost = new Label("How much you own: ");
        Label TotalCostResult = new Label(" ");

        field1 = new TextField();
        field2 = new TextField();
        field3 = new TextField();
        field4 = new TextField();
        field5 = new TextField();
        field6 = new TextField();//all textfield

        submitButton = new Button ("Submit"); //Create submit button
        submitButton.setDisable( true);
        cancelButton = new Button ("Cancel"); //Create Cancel button


        HBox hBox = new HBox(20, label1, field1);
        HBox hBox1 = new HBox(10, label2);
        HBox hBox2 = new HBox(15, label3, field2);
        HBox hBox3 = new HBox(10, label4, field3);
        HBox hBox4 = new HBox(12, label5, field4);
        HBox hBox5 = new HBox(32, label6, field5);
        HBox hBox6 = new HBox(75, label7, field6);
        HBox hBox7 = new HBox(20, submitButton, cancelButton);
        HBox hBox8 = new HBox(20, TotalExpensive, TotalExpensiveResult);
        HBox hBox9 = new HBox(20, TotalCost, TotalCostResult);


        hBox.setAlignment(Pos.BASELINE_RIGHT); //Alignment
        hBox1.setAlignment(Pos.BASELINE_LEFT);
        hBox2.setAlignment(Pos.BASELINE_RIGHT);
        hBox3.setAlignment(Pos.BASELINE_RIGHT);
        hBox4.setAlignment(Pos.BASELINE_RIGHT);
        hBox5.setAlignment(Pos.BASELINE_RIGHT);
        hBox6.setAlignment(Pos.BASELINE_RIGHT);
        hBox7.setAlignment(Pos.CENTER);
        hBox8.setAlignment(Pos.BASELINE_LEFT);
        hBox9.setAlignment(Pos.BASELINE_LEFT);



        hBox1.setPadding(new Insets(0,0,15,0));
        hBox3.setPadding(new Insets(0,0,15,0));
        hBox7.setPadding(new Insets(15,0,0,0));
        hBox8.setPadding(new Insets(0,0,15,0));
        hBox9.setPadding(new Insets(0,0,15,0));

        TextFieldListener listener = new TextFieldListener();
        field1.textProperty().addListener(listener);
        field2.textProperty().addListener(listener);
        field3.textProperty().addListener(listener);
        field4.textProperty().addListener(listener);
        field5.textProperty().addListener(listener);
        field6.textProperty().addListener(listener);



        GridPane gridPane = new GridPane ();

        gridPane.add(hBox, 0, 0);
        gridPane.add(hBox1, 0, 1);
        gridPane.add(hBox2, 0, 2);
        gridPane.add(hBox3, 0, 3);
        gridPane.add(hBox4, 0, 4);
        gridPane.add(hBox5, 0, 5);
        gridPane.add(hBox6, 0, 6);
        gridPane.add(hBox7, 0, 7);
        gridPane.add(hBox8, 0, 8);
        gridPane.add(hBox9, 0, 9);
        gridPane.setAlignment(Pos.CENTER);
        gridPane.setPadding( new Insets(20, 20, 20, 20));
        gridPane.setVgap( 10);
        gridPane.setHgap( 10);
        primaryStage.setTitle("Travel Expenses Calculator");
        primaryStage.setScene(new Scene (gridPane));
        primaryStage.show();

        submitButton.setOnAction(event ->
        {

            double days = Double.parseDouble(field1.getText());
            double airFare = Double.parseDouble(field2.getText());
            double miles = Double.parseDouble(field3.getText());
            double ConregCost = Double.parseDouble(field4.getText());
            double lodgingCost = Double.parseDouble(field5.getText());
            double foodCost = Double.parseDouble(field6.getText());

            TotalExpensiveResult.setText(" " + ( airFare+ foodCost + ConregCost + (days * lodgingCost)) );

        });





    }

    private class TextFieldListener implements ChangeListener<String>
    {
        @Override
        public void changed(ObservableValue<? extends String> source, String oldValue, String
                newValue)
        {
            String numTrip = field1.getText();
            String airFare = field2.getText();
            String miles = field3.getText();
            String confCost = field4.getText();
            String lodgingCost = field5.getText();
            String foodCost = field6.getText();

            if (airFare.trim().equals( "")  )
            {
                submitButton.setDisable(numTrip.trim().equals( "") ||miles.trim().equals( "") || confCost.trim().equals( "")||
                        lodgingCost.trim().equals( "")|| foodCost.trim().equals( ""));
            }

            else if (miles.trim().equals( "") )
            {
                submitButton.setDisable(numTrip.trim().equals( "") ||airFare.trim().equals( "") || confCost.trim().equals( "")||
                        lodgingCost.trim().equals( "")|| foodCost.trim().equals( ""));
            }

            else
            {
                submitButton.setDisable( true);
            }


        }
    };




    public static void main(String[] args) {
        launch(args);
    }
}

In: Computer Science

A portfolio manager has maintained an actively managedportfolio with a beta of 0.2. During the...

A portfolio manager has maintained an actively managed portfolio with a beta of 0.2. During the last year, the risk-free rate was 5% and major equity indices performed very badly, providing returns of about −30%. The portfolio manager produced a return of −10% and claims that in the circumstances it was good.

A) Discuss this claim, was it a good return, why or why not?

B) What is the expected return on a portfolio with a beta of 0.2? (Show your calculation)

In: Finance

Biochemical oxygen demand i.e. BOD) is a measure of the potential damage that can be done...

Biochemical oxygen demand i.e. BOD) is a measure of the potential damage that can be done to the dissolved oxygen content of a body of water by organic waste. A BOD is also the amount of O2required to degrade or decompose the wastes. Its name comes from the "demand" that organic carbon has for O2 through biochemical (enzyme) oxidation.

BOD – demanded oxygen – can be likened to a debt that must be paid. Dissolved oxygen (DO) can be thought of as the currency used to pay the debt. If DO (assets) exceeds BOD (debt), aerobic conditions (economic solvency) will prevail. If BOD exceeds DO, bankruptcy may ensue. Bankruptcy, in this case, is the depletion of water's chief asset, O2. Over a period of time, the water's oxygen level is usually replenished by oxygen from the air. The length of this time period depends on the severity of the initial loss of oxygen.

If we assume that the part of the organic waste that is being degraded is carbon, C ( a good assumption), then we can write the following chemical formula:

C + O2 ? CO2

If we were to do a mass analysis (i.e. gram for gram, pound for pound, etc.) of this equation, we would find that for every 3 parts of C, we would need 8 parts of O2. If you're thinking that it looks like it should be a one for one deal, you're absolutely correct. It does in fact require one MOLECULE of carbon to react with one MOLECULE of oxygen, but if we would weigh those molecules we'd see that different molecules weigh different amounts and therefore based on mass, we'd get the 3:8 ratio.

Do not overthink this problem. If you think along the lines of a is to b as x is to y, you'll be on the right track.

Enter ONLY the answer in the provided answer box.

QUESTION 1

Consider a small lake, 0.3 miles across and 8 ft deep, that contains a total of 40 tons of dissolved oxygen. Calculate the BOD (i.e.calculate the amount of oxygen required to degrade the amount of organic waste given) if 6 tons of carbon-based waste is dumped into the lake. Round your answer to zero places past the decimal.

Question 2

Repeat the BOD calculation as done in #1, but this time let's dump in 32 tons of carbon-based waste. Round your answer to zero places past the decimal.

QUESTION 3

The differences between the two cases above include all of the following: (Select all that apply)

A.

In the first case there is plenty of oxygen to go around but not enough in the second case.

B.

The BOD in the second case is larger than that in the first case.

C.

The BOD in the first case is exactly the same as the COD.

D.

In the first case there is a chance that the lake could recover.

E.

Chances are, in the second case the lake will not recover.

In: Other

3. Suppose that the production function is CobbDouglas with parameter α = 0.3. a. What fractions...

3. Suppose that the production function is CobbDouglas with parameter α = 0.3.

a. What fractions of income do capital and labour receive?

b. Suppose that immigration raises the labour force by 10 percent. What happens to total output (in percent)? The rental price of capital? The real wage?

c. Suppose that a gift of capital from abroad raises the capital stock by 10 percent. What happens to total output (in percent)? The rental price of capital? The real wage?

please explain it like how to they get digits from suddenly out of no where

d. Suppose that a technological advance raises the value of the parameter A by 10 percent. What happens to total output (in percent)? The rental price of capital? The real wage?

In: Economics

String is wrapped around an object of mass M = 0.3 kg and moment of inertia...

String is wrapped around an object of mass M = 0.3 kg and moment of inertia I = 0.01 kg·m2. You pull the string with your hand straight up with some constant force F such that the center of the object does not move up or down, but the object spins faster and faster (see the figure). This is like a yo-yo; nothing but the vertical string touches the object. When your hand is a height y0 = 0.26 m above the floor, the object has an angular speed 0 = 14 radians/s. When your hand has risen to a height y = 0.66 m above the floor, what is the angular speed of the object? Your answer must be numeric and not contain the symbol F.

In: Physics

The proportion of customers who do online shopping is believed to be 0.3. A survey of49...

The proportion of customers who do online shopping is believed to be 0.3. A survey of49 customers was taken. They were asked if they did online shopping. A. What is the probability of the sample proportion to be below 0.25? B. What is the probability that the sample mean is above 0.35? C. What is the role of the central limit theorem in solving this problem?

In: Statistics and Probability