1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
iogann1982 [59]
3 years ago
5

Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year, vin number, miles per ga

llon, and speed. Include get and set methods for each field. Do not allow the ID to be negative or more than 9999; if it is, set the ID to 0. Do not allow the year to be earlier than 2000 or later than 2017; if it is, set the year to 0. Do not allow the miles per gallon to be less than 10 or more than 60; if it is, set the miles per gallon to 0. Car speed should be initialized as 0. Include a constructor that accepts arguments for each field value and uses the set methods to assign the values. Also, write two methods, Accelerate () and Brake (). Whenever Accelerate () is called, increase the speed by 5, and whenever Brake () is called, decrease the speed by 5. To allow users to specify the speed to increase (or decrease), create two overloading methods for Accelerate () and Brake () that accept a single parameter specifying the increasing (or decreasing) speed. Write an application that declares several Automobile objects and demonstrates that all the methods work correctly. Save the files as Automobile.java and TestAutomobiles.java.
Computers and Technology
1 answer:
aliya0001 [1]3 years ago
4 0

Answer:

public class TestAutomobiles {

   public static void main(String args[]) {

     Automobile obj = new Automobile(1, "Wolkswagen", "Golf", 2007, "GR1GR", 20, 120, "Grey");

  System.out.println("Initial Speed: " + obj.getSpeed());

  System.out.println("Current Speed with acceleration 100: " + obj.accelerate(100));

  System.out.println("Current Speed after using brake : " + obj.brake());

   }

}

class Automobile {

    private int idNumber, year, milesPerGallon, speed = 0;

    private String model, vinNumber, make, color;

   

    public void setIdNumber(int idNumber){

       if (idNumber >= 0 && idNumber <= 9999)

           this.idNumber = idNumber;

       else this.idNumber = 0;

    }

    public void setModel(String model){

        this.model = model;

    }

    public void setYear(int year){

       if (year >= 2000 && year <= 2017)

           this.idNumber = idNumber;

       else this.year = 0;

    }

    public void setVinNumber(String vinNumber){

        this.vinNumber = vinNumber;

    }

    public void setMilesPerGalon(int milesPerGallon){

       if (milesPerGallon >= 10 && year <= 60)

           this.milesPerGallon = milesPerGallon;

       else this.milesPerGallon = 0;

    }

    public void setSpeed(int speed){

        this.speed = speed;

    }

    public void setMake(String make){

        this.make = make;

    }

    public void setColor(String color){

        this.color = color;

    }

    public int getIdNumber(){return idNumber;}

    public String getModel(){return model;}

    public int getYear(){return year;}

    public String getVinNumber(){return vinNumber;}

    public int getMilesPerGallon(){return milesPerGallon;}

    public int getSpeed(){return speed;}

    public String getMake(){return make;}

    public String getColor(){return color;}

   

   public int accelerate() {

       setSpeed(speed + 5);

       return speed;

   }

   public int brake() {

       setSpeed(speed - 5);

       return speed;

   }

   public int accelerate(int s) {

       setSpeed(speed + s);

       return speed;

   }

   public int brake(int s) {

       setSpeed(speed - s);

       return speed;

   }

   

    public Automobile(int idNumber, String make, String model, int year, String vinNumber, int milesPerGallon, int speed, String color){

       setIdNumber(idNumber);

       setModel(model);

       setYear(year);

       setVinNumber(vinNumber);

       setMilesPerGalon(milesPerGallon);

       setSpeed(speed);

       setMake(make);

       setColor(color);

    }

}

Explanation:

Required <em>variables</em> are declared as private members.

Their <em>setters</em> and <em>getter</em> are created.

Two <em>accelearate</em> and two <em>break</em> methods are created.

One <em>constructor</em> taking all variables as parameter is created.

In the main, I tested a few functions to check if they work properly.

You might be interested in
1) Using the density equation d=m/V: What is the density of a piece of metal with a mass o
kolezko [41]

Answer:

density= 7.8214 g/cm^3

Explanation:

Mass = m = 87.6 g

Volume = V = 11.2 cm^3

density = m/v

            = 87.6 g/ 11.2cm^3

            = 7.8214 g/cm^3

4 0
3 years ago
One is FPGA and other is ASIC. Budget, power consumption, and speed are the common parameters considered for the selection of th
Sati [7]

Answer:

FPGA is an abbreviation for Field Programmable Gate Array while ASICS is an abbreviation of Application Specific Integrated Circuit. By considering the parameters like speed budget and power consumption, I will prefer FPGA as it has short design cycle. FPGA also has a development kit that helps while prototyping. Using FPGA all the required parameters will be provided in satisfied way.

However if one fails while using FPGA the he/she could move towards ASICS.

ASICS on the other hand has following factors:

  • less power consumption
  • less area
  • more speed

ASICS is preferred when one needs larger volume as ASICS has longer design and prototyping cycles.

<h3>I hope it will help you!</h3>

3 0
3 years ago
PLEASE HELP! I'm offering brainliest!
Marina CMI [18]

Answer:

1. Undo  2. Font Type   3. Font Size  4. Bold Font 5. <em>Italics  </em>6. Word Color  7.  Document Margins

Explanation:

Did you know that all of these answers are how to format a document?

7 0
2 years ago
For this project you will write a Java program that will run a simple math quiz. Your program will generate two random integers
ElenaW [278]

Answer:

Here is the JAVA program:

import java.util.Scanner;   //to accept input from user

public class FunWithBranching {   //class name

   public static void main(String[] args) {  //start of main function

   Scanner input = new Scanner(System.in);  //creates Scanner object

   System.out.print("Enter your name: "); //prompts user to enter name

   String userName = input.nextLine();  //stores the name

   System.out.print("Welcome " + userName + "! Please answer the following questions:\n");   //prompts user to answer the questions

   int randomOperand1 =  (int)(20 * Math.random()) + 1;  //generates random number for operand 1 (1-20)

   int randomOperand2 =  (int)(20 * Math.random()) + 1;  //generates random number for operand 2 (1-20)

   int randomAdd = randomOperand1 + randomOperand2;  //performs addition of two random numbers and stores result in randomAdd

   int randomMul = randomOperand1 * randomOperand2;  //performs multiplication of two random numbers

   int randomDiv = randomOperand1 / randomOperand2;  //performs division of two random numbers

   int randomMod = randomOperand1 % randomOperand2;  //performs modulo of two random numbers

   int correctAns = 0;  //stores number of correct answers

   System.out.print(randomOperand1 + " + " + randomOperand2 + " = ");  //displays random number + random number

   int AdditionGuess = input.nextInt();   //reads the answer of addition from user and stores it in AdditionGuess

   if (AdditionGuess == randomOperand1 + randomOperand2) {  //if the user answer is correct

   System.out.println("Correct!");  //displays correct

   correctAns++;  //adds 1 to the count of correctAns every time the user gives correct answer of addition

 } else {  //if user answer is incorrect

   System.out.println("Wrong!");  //displays wrong

   System.out.println("The correct answer is " + randomAdd);   }  //displays the correct answer of addition

   System.out.print(randomOperand1 + " * " + randomOperand2 + " = ");  //displays random number * random number  

   int MultiplicationGuess = input.nextInt();   //reads the answer of multiplication from user and stores it in MultiplicationGuess

 if (MultiplicationGuess == randomOperand1 * randomOperand2) {  //if the user answer is correct

     System.out.println("Correct!");  //displays correct

     correctAns++;  //adds 1 to the count of correctAns every time the user gives correct answer of multiplication

 }else{  //if user answer is incorrect

       System.out.println("Wrong!");  //displays wrong

       System.out.println("The correct answer is " + randomMul);   }  //displays the correct answer of multiplication

   System.out.print(randomOperand1 + " / " + randomOperand2 + " = ");  //displays random number / random number  

   int DivisionGuess = input.nextInt();   //reads the answer of division from user and stores it in DivisionGuess

   if (DivisionGuess == randomOperand1 / randomOperand2) {  //if the user answer is correct

       System.out.println("Correct!");  //displays correct

       correctAns++;   //adds 1 to the count of correctAns every time the user gives correct answer of division

       }else{  //if user answer is incorrect

           System.out.println("Wrong!");  //displays wrong

           System.out.println("The correct answer is " + randomDiv);     }  //displays the correct answer of division

      System.out.print(randomOperand1 + " % " + randomOperand2 + " = ");  //displays random number % random number  

       int ModGuess = input.nextInt();  //reads the answer of modulo from user and stores it in ModGuess

           if (ModGuess == randomOperand1 % randomOperand2) {  //if the user answer is correct

           System.out.println("Correct!");  //displays correct

           correctAns++;   //adds 1 to the count of correctAns every time the user gives correct answer of modulo

           }else{  //if user answer is incorrect

               System.out.println("Wrong!");  //displays wrong

               System.out.println("The correct answer is " + randomMod);    }  //displays the correct answer of modulo

double percentage = correctAns * 25;   //computes percentage

System.out.println("You got " + correctAns + " correct answers.");   //display number of correct answers given by user

System.out.println("That's " + percentage + "%!");         }  } //displays percentage

Explanation:

The program is well explained in the comments mentioned with each line of code. The screenshot of the output is attached.

3 0
3 years ago
What impact did congress declaration on copyrighting sound recordings have on home recording and record sales
cricket20 [7]

Answer:

By the late 1980s, several manufacturers were prepared to introduce read/write digital audio formats to the United States. These new formats were a significant improvement over the newly introduced read-only (at the time) digital format of the compact disc, allowing consumers to make perfect, multi-generation copies of digital audio recordings. Most prominent among these formats was Digital Audio Tape (DAT), followed in the early 1990s by Philips' Digital Compact Cassette (DCC) and Sony's Minidisc.

DAT was available as early as 1987 in Japan and Europe, but device manufacturers delayed introducing the format to the United States in the face of opposition from the recording industry. The recording industry, fearing that the ability to make perfect, multi-generation copies would spur widespread copyright infringement and lost sales, had two main points of leverage over device makers. First, consumer electronics manufacturers felt they needed the recording industry's cooperation to induce consumers – many of whom were in the process of replacing their cassettes and records with compact discs – to embrace a new music format. Second, device makers feared a lawsuit for contributory copyright infringement.[1]

Despite their strong playing hand, the recording industry failed to convince consumer electronics companies to voluntarily adopt copy restriction technology. The recording industry concurrently sought a legislative solution to the perceived threat posed by perfect multi-generation copies, introducing legislation mandating that device makers incorporate copy protection technology as early as 1987.[2] These efforts were defeated by the consumer electronics industry along with songwriters and music publishers, who rejected any solution that did not compensate copyright owners for lost sales due to home taping.[3]

The impasse was broken at a meeting in Athens in 1989, when representatives from the recording industry and the consumer electronics industry reached a compromise intended to enable the sale of DAT recorders in the United States. Device manufacturers agreed to include SCMS in all consumer DAT recorders in order to prevent serial copying. The recording industry would independently pursue legislation requiring royalties on digital audio recording devices and media.[4]

A year later the songwriter Sammy Cahn and four music publishers, unhappy with the absence of a royalties provision in the Athens agreement, filed a class action copyright infringement suit against Sony.[5] The plaintiffs sought declaratory and injunctive relief that would have prevented the manufacture, importation or distribution of DAT recorders or media in the United States. The suit brought Sony to heel. In July 1991, Sony, as part of larger agreement between the recording industry and consumer electronics makers, agreed to support legislation creating a royalty scheme for digital media. In exchange, Cahn and the publishers agreed to drop the suit.[6]

With all the major stakeholders satisfied, the bill easily passed both houses of Congress. President George H. W. Bush signed the AHRA into law in 1992 proclaiming " S. 1623 [AHRA] will ensure that American consumers have access to equipment embodying the new digital audio recording technology. It also protects the legitimate rights of our songwriters, performers, and recording companies to be fairly rewarded for their tremendous talent, expertise, and capital investment. This will be accomplished by fairly compensating these artists for the copying of their works and by creating a system that will prevent unfettered copying of digital audio tapes."

3 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program that estimates the approximate number of times the user’s heart has beat in his/her lifetime using an average he
    12·1 answer
  • What kind of game was Pole Position?
    14·1 answer
  • A network engineer is configuring a network to be able to relay IPv6 packets. The network only supports IPv4 and does not have d
    11·1 answer
  • Într-o curte sunt G găini și O oi. Să se determine numărul de capete și numărul de picioare din curte.
    13·1 answer
  • Outlines are effective because
    13·2 answers
  • Outline the dangers arising as a result of using computers​
    12·1 answer
  • What is the alogarithm for solving the perimeter of a triangle
    11·1 answer
  • What would give Lucy, an entry-level candidate, an edge over others while she seeks a programmer’s position? Lucy, an entry-leve
    11·1 answer
  • Choose the response that best completes the following statement.
    14·2 answers
  • China's cultural diversity, China is composed of 56 ethnic groups.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!