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
Neko [114]
3 years ago
4

Given two integers that represent the miles to drive forward and the miles to drive in reverse as user inputs, create a SimpleCa

r object that performs the following operations:Drives input number of miles forwardDrives input number of miles in reverseHonks the hornReports car statusThe SimpleCar class is found in the file SimpleCar.java.100 4the output is:beep beepCar has driven: 96 milesimport java.util.Scanner;public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }}
Computers and Technology
1 answer:
Ira Lisetskai [31]3 years ago
6 0

Answer:

Explanation:

The following code is written in Java. It creates the SimpleCar class with the variables for position, milesForward, and milesReverse. It contains the constructor, Honk, reportStatus, and setter methods needed and as requested. The scanner object is created in the main method and asks the user for the number of miles forward as well as the number of miles in reverse. A test case was created and the output can be seen in the attached image below.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("How many miles forward did the car drive?");

       int forward = in.nextInt();

       System.out.println("How many miles in reverse did the car drive?");

       int reverse = in.nextInt();

       SimpleCar beep = new SimpleCar(forward, reverse);

       beep.Honk();

       beep.reportStatus();

   }

}

class SimpleCar {

   int position;

   int milesForward;

   int milesReverse;

   public SimpleCar(int milesForward, int milesReverse) {

       this.milesForward = milesForward;

       this.milesReverse = milesReverse;

       this.position = 0;

   }

   public void Honk() {

       System.out.println("HONK");

   }

   public void reportStatus() {

       position = milesForward - milesReverse;

       System.out.println("Car is " + position + " miles from starting point.");

   }

   public void setMilesForward(int milesForward) {

       this.milesForward = milesForward;

       this.position += milesForward;

   }

   public void setMilesReverse(int milesReverse) {

       this.milesReverse = milesReverse;

       this.position -= milesReverse;

   }

}

You might be interested in
True or False: Visual Studio is not a part of Unity. You could use a different code editor to edit your C# scripts if you wanted
gizmo_the_mogwai [7]

Answer:

True

Explanation:

Visual Studio and Unity are two different things. Visual Studio is an IDE developed by Microsoft, and Unity is a game engine developed by another company. Visual Studio is the default editor in Unity, but you are able to use something different.

Source: https://docs.unity3d.com/Manual/ScriptingToolsIDEs.html

7 0
3 years ago
What are two examples of items in Outlook?
marta [7]

Answer:

I believe it would be button and tool bar

8 0
3 years ago
It's important to understand that even information systems that do not use computers
Delvig [45]

Answer:

yes I am not sure if you have any questions or concerns please visit the plug-in settings to determine how attachments are handled the situation in the measurements of the season my dear friend I am not sure if you can send you a great day to day basis of

6 0
3 years ago
What effect does using quotas in file server resource manager have?
andrezito [222]
It limits the number of gigabytes allocated to a volume or folder
5 0
3 years ago
What important information is added to the TCP/IP transport layer header to ensure communication and connectivity with a remote
kramer

Answer:

<em>Source port numbers and Destination </em>

Explanation:

Sockets are also <em>known as the source and destination IP addresses are combined with the  source and destination port numbers.  </em>

The socket is used to define the client's request for server and network.  

Thousands of hosts are communicating with millions of separate servers every day.

5 0
4 years ago
Other questions:
  • What is being measured using kbps, mbps, and gbps?
    7·1 answer
  • What are some objects in your home that demonstrate electrical energy to radiant energy to thermal energy
    10·2 answers
  • How can our perceptions help us to choose the channel for our message?
    5·1 answer
  • What is a systems development life cycle?
    5·1 answer
  • Computer design replaced ______________
    6·1 answer
  • Why is printer an output device​
    14·2 answers
  • If an image has only 4 colors, how many bits are necessary to represent one pixel’s color? Describe a new custom encoding that u
    8·1 answer
  • In most software programs, which color arrows selects the points in a vector
    14·1 answer
  • The method "someOtherMethod" is NOT defined as static. This means...
    5·1 answer
  • Who is better, Tom, Ben, Hank, Angela, or Ginger
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!