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
n200080 [17]
2 years ago
10

A combination lock has the following basic properties:

Computers and Technology
1 answer:
fomenos2 years ago
5 0

Answer:

public class CombinationLock {

   

    private int combinationNumber1 = 0;

    private int combinationNumber2 = 0;

    private int combinationNumber3 = 0;

   

   CombinationLock(int combinationNumber1, int combinationNumber2, int combinationNumber3){

       this.combinationNumber1 = combinationNumber1;

       this.combinationNumber2 = combinationNumber2;

       this.combinationNumber3 = combinationNumber3;

   }

   

   public boolean open(int number1, int number2, int number3){

       if(number1 == combinationNumber1 && number2 == combinationNumber2 && number3 == combinationNumber3)

           return true;

       else

           return false;

   }

   

   public boolean changeCombo(int number1, int number2, int number3, int newNumber1, int newNumber2, int newNumber3){

       

       if (open(number1, number2, number3)){

           combinationNumber1 = newNumber1;

           combinationNumber2 = newNumber2;

           combinationNumber3 = newNumber3;

           return true;

       }else

           return false;

   }

}

Explanation:

- <em>Three variables</em> are created to hold the combination.

- A <em>constructor</em> is created to set the combination.

- A boolean method called <em>open</em> is created to check if the given numbers are correct, and <u>returns true</u> (<u>otherwise returns false</u>).

- A boolean method method called <em>changeCombo</em> is created to check if given numbers are correct. If they are correct, it assigns new values for the combination and <u>returns true</u> (<u>otherwise returns false</u>).

You might be interested in
Design a program that asks the user to enter a store’s sales for each day of the week. The amounts should be stored in an array.
sdas [7]

Answer:

Program given below

Explanation:

Total Sales

Assign the values of the variable as “Enter the store sales for Sunday” in Sun

Assign the values of the variable as “Enter the store sales for Monday” in Mon

Assign the values of the variable as “Enter the store sales for Tuesday” in Tue

Assign the values of the variable as “Enter the store sales for Wednesday” in Wed

Assign the values of the variable as “Enter the store sales for Thursday” in Thu

Assign the values of the variable as “Enter the store sales for Friday” in Fri

Assign the values of the variable as “Enter the store sales for Saturday” in Sat

Assign the values for the variable in array as [Sun, Mon, Tue, Wed, Thu, Fri, Sat]

Initialize tot = 0

Use the loop for calculating the total sales for the week,

for total_sales in store_sales:

    tot += total_sales

then display the result as,    

print "\n Total week sales = %2.f " %tot

sun = int(input("\n Enter the store sales for Sunday: "))

mon = int(input("\n Enter the store sales for Monday: "))

tue = int(input("\n Enter the store sales for Tuesday: "))

wed = int(input("\n Enter the store sales for Wednesday: "))

thu = int(input("\n Enter the store sales for Thursday: "))

fri = int(input("\n Enter the store sales for Friday: "))

sat = int(input("\n Enter the store sales for Saturday: "))

store_sales = [sun, mon, tue, wed, thu, fri, sat]

tot = 0

for store_sale in store_sales:

tot += store_sale

print "\n Total Week Sales: %2.f" %tot

We will have the following output:

<u>OUTPUT </u>

<u> </u>Enter the store sales for Sunday: 45

Enter the store sales for Monday: 56

Enter the store sales for Tuesday: 89

Enter the store sales for Wednesday:78

Enter the store sales for Thursday: 45

Enter the store sales for Friday: 12

Enter the store sales for Saturday: 23

Total Week Sales: 348

8 0
3 years ago
Assume that word is a variable of type String that has been assigned a value. Assume furthermore that this value always contains
Valentin [98]

Answer:

   String word = "George slew the dragon";

   

   int pos = word.indexOf("dr");    

   String drWord = word.substring(pos, pos+4);

   

   System.out.println(drWord);

Explanation:

Assuming dr is always there, we don't have to check the validity of 'pos'. Normally, you would!

5 0
3 years ago
Read 2 more answers
Will a debit card still work if i put stickers on it?
laiz [17]

Answer:

Explanation:

Yes, it may still be readable, but if they refuse to take it you have no ground to stand on. (If you obscure the signature, at least make sure the CVV is readable or reprinted on top.) The plastic covering should not interfere with the mag stripe.

8 0
3 years ago
Read 2 more answers
What is a primary feature of a digital video camera?
masha68 [24]
The primary feature of a digital video camera is to records video as digital signals. A digital video camera picture out as of live settings, encrypting it into information that can be definite or transcoded into electronic photographic media. A typical digital camera contains of a lens, image sensor, storing media and a number of other characteristics that can be also be initiated on other cameras such as scalable aperture, filters and flash. High feature images and digital video slides can be put in storage and replicated on a computer, CD or writable DVD or on the internet in deprived of any loss of quality.
4 0
3 years ago
Why does angular page look different after refresh.
alukav5142 [94]
Most of the web applications are written with SPA frameworks such as Angular, React, Vue.js, etc. The problem with these SPAs is that the single page is loaded in the browser once and then the framework will take care of all the routing among pages and gives the impression to the user that it is a multi-page application. When you refresh your page in the browser that single page called index.html is reloaded and you will lose the entire state of the application.
3 0
2 years ago
Other questions:
  • ________ employees state-of-the-art computer software and hardware to help people work better together.
    15·1 answer
  • Describe how computer is in the last 35 years
    6·1 answer
  • Write a class called Line that represents a line segment between two Points. Your Line objects should have the following methods
    8·1 answer
  • Compared to a virtual image, a real image
    15·2 answers
  • Power delivered to the hitch of tractors is called
    12·1 answer
  • What do people do when they navigate using GPS
    6·2 answers
  • To simplify the conceptual design, most higher-order relationships are decomposed into appropriate equivalent _____ relationship
    11·1 answer
  • Where is the third vanishing point in the three point perspective
    8·1 answer
  • HELPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP!!!
    12·1 answer
  • Your program will be used by many departments at the university. Your comments will be important to their IT people. What would
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!