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
Scorpion4ik [409]
4 years ago
13

Write the code that creates a public class named Vehicle that has one private data member. The private data member is an integer

variable named modelYear. Create two constructors: Code a constructor that has no parameters and initializes the modelYear variable to 2018. Code a constructor that has one parameter and uses that parameter value to update the modelYear variable.
Computers and Technology
1 answer:
maxonik [38]3 years ago
3 0

Answer:

Following are the program in java

public class Vehicle // class vehicle of type public

{

private int modelYear;

Vehicle() //  no parameters

{

modelYear=2018;

}

vehicle(int t)  // update the value of modelYear

{

modelYear=t;

}

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

{

vehicle ob=new vehicle();// creating instance

vehicle ob1=new vehicle(45);

}

}

Explanation:

Here we create a private data member i.e modelYear of integer type .

We create default constructor and initializes modelYear variable  with 2018.

we create a parametrized constructor  which update the value of modelYear variable.

From the main function we call both the constructors.

You might be interested in
(Solved—15 Lines) In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one
andrezito [222]

Answer:

JAVA program is given below.

import java.util.Scanner;

public class Main

{

   //static variables declared and initialized as required

   static float deposit1 = 0.10f;

   static float deposit2 = 0.25f;

   static float refund1;

   static float refund2;

   static int num_one_lit;

   static int num_more;

public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the number of containers of 1 liter or less: ");

 num_one_lit = sc.nextInt();

 System.out.print("Enter the number of containers of more than 1 liter: ");

 num_more = sc.nextInt();

 //refund computed based on user input

 refund1 = num_one_lit*deposit1;

 refund2 = num_more*deposit2;

 //displaying refund

 System.out.printf("Total refund amount for containers of 1 liter or less is $%.2f %n", refund1);

 System.out.printf("Total refund amount for containers of more than 1 liter is $%.2f %n", refund2);

}

}

OUTPUT

Enter the number of containers of 1 liter or less: 5

Enter the number of containers of more than 1 liter: 2

Total refund amount for containers of 1 liter or less is $0.50  

Total refund amount for containers of more than 1 liter is $0.50

Explanation:

1. Variables are declared at class level hence declared as static.

2. Variables holding deposit also initialized with the given values.

3. User input is taken for the number of containers in both categories.

4. The total value of refund is computed using the given values and user entered values.

5. The total refund is displayed to the user for both categories.

6. To display two decimal places always, variables to hold deposit and refund are declared as float.

7. The keywords used for decimals are %.2f %n. The %.2f keyword indicates two decimal places to be displayed in float variable, %n indicates a numeric value is to be displayed.

8. The printf() method is used to display the formatted output for refund amount.

9. The keywords used to display the formatted output is derived from C language.

10. All the code is written inside class and execution begins from the main() method.

4 0
4 years ago
The RAND() function in Excel returns a pseudo-random number between 0 and 1. If you enter this function into 1000 cells (i.e. en
Neko [114]

Answer:

To get this, filter the column with the condition "less than or equal 0.1" and check the number of returned rows at the bottom of the worksheet ( mine is 87 rows from 1000).

Explanation:

The RAND() function in Microsoft Excel is used to generate random numbers between zero and one. It can also be used to generate a range of numbers with decimal places by multiplying the stop number with the rand function  

4 0
3 years ago
Which of the following most closely illustrates the correct format of the comparison in a conditional statement?
hoa [83]
Answer should be if (thisString = "What is your quest?")
6 0
3 years ago
Using tracking code, Google Analytics can report on data from which systems? (select all answers that apply)
Jobisdone [24]

Answer:

a b c

Explanation:

they can report data from these three options

6 0
3 years ago
Have you been tempted to do something online that you wouldn't do if<br> people knew it was you?
Aleksandr-060686 [28]

Answer

I don't know tbh, Maybe once or twice here or there.

Explanation:

6 0
3 years ago
Other questions:
  • Which type of view is created from the following SQL statement? CREATE VIEW balancedue AS SELECT customer#, order#, SUM(quantity
    15·1 answer
  • During the analysis phase of the SDLC the systems analyst will decide how the hardware, software and network infrastructure, use
    5·1 answer
  • When a crash results in property damages of any amount, the driver must notify:
    10·1 answer
  • In order to create a multi-line comment, what symbol do you use?
    14·1 answer
  • What should be included in research for a problem statement? Select all that apply
    13·2 answers
  • Make a presentation on ms word
    6·2 answers
  • c) If you are at foreign country visit, which banking card would you prefer to keep with you during visit (Debit Card or Credit
    10·1 answer
  • What methods do you use when researching a complicated or difficult subject? What tools are most useful to narrowing down and va
    12·1 answer
  • An operating system with _____ capabilities allows a user to run more than one program concurrently.
    6·1 answer
  • In an etl process, data is loaded into a final target database such as:______
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!