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
Bess [88]
2 years ago
13

Write a class called SimpleSquare that has the following properties: - public int field called num - private int field called sq

uare - a constructor that takes a single parameter that sets the num, then sets square to num to the second power
Computers and Technology
1 answer:
mezya [45]2 years ago
6 0

Answer:

public class SimpleSquare{

   public int num;

   private int square;

   

   public SimpleSquare(int number){

       num = number;

       square = number * number;

   }

   

   public int getSquare(){

       return square;

   }    

}

Explanation:

*The code is in Java.

Create a class called SimpleSquare

Declare two fields, num and square

Create a constructor that takes an integer number as a parameter, sets the num and sets the square as number * number.

Since the square is a private field, I also added the getSquare() method which returns the value of the square.

You might be interested in
Suppose for the worst case, given input size n: Algorithm 1 performs f(n) = n2 + n/2 steps Algorithm 2 performs f(n) = 12n + 500
melomori [17]

Answer:

29

Explanation:

for n=28:

--------------

Algorithm 1 performs f(n) = n2 + n/2 = 28*28 + 28/2 = 798

Algorithm 2 performs f(n) = 12*28 + 500 = 836

for n=29

--------------

Algorithm 1 performs f(n) = n2 + n/2 = 29*29 + 29/2 = 855.5

Algorithm 2 performs f(n) = 12*29 + 500 = 848

so, for n=29, algorithm 2 will be faster than algorithm 1

6 0
2 years ago
((Excel)) please help, 100 points, and brain crown thingy, not only that, i will make several of these so you can get several hu
cupoosta [38]

Answer:

First you read the question and numbers, then you use the numbers in the correct way and you try reallllyyy hard, you will find your answer! Hope this helps! :D

4 0
2 years ago
Prove the following assertion: For every game tree, the utility obtained by MAX using minimax decisions against a suboptimal MIN
TiliK225 [7]

Answer:

From the given diagram, consider a MIN node whose children are terminal nodes, if MIN plays  

suboptimal. MIN will never be lower than the utility obtained playing against an optimal MIN  

MIN will always select a move having minimax utility greater than or equal to the move that is  

predicted by the minimax that is the MIN-played optimal value.  

Then the MIN node's value is increased to MAX. This is done by induction.  

One can do better than the minimax strategy, if the suboptimal play is predicted by MIN.

If MIN always falls for certain for certain kind of trap and losses, then setting up a trap guarantees a win.

Explanation:

See attached picture also.

5 0
3 years ago
Write a function call it isEvenPositiveInt which takes an integer x and return true if x is positive and also even. Note isinsta
Anna11 [10]

Answer:

The program to this question as follows:

Program:

def isEvenPositiveInt(x): #defining method isEvenPositiveInt

   if x>0: #checking number is positive or not

       if x%2==0: #check true condition

           return True #return value True

       else:

           return False #return value False

   return False #return value False

print(isEvenPositiveInt(24)) #calling method and print return value

print(isEvenPositiveInt(-24)) #calling method and print return value

print(isEvenPositiveInt(23)) #calling method and print return value

Output:

True

False

False

Explanation:

In the above Python program, a method "isEvenPositiveInt" is defined, that accepts a variable "x" as its parameter, inside the method a conditional statement is used, which can be described as follows:

  • In the if block the condition "x>0" is passed, that check value is positive, if this condition is true, it will go to another if block.
  • In another, if block is defined, that checks the inserted value is even or not, if the value is even it will return "true", otherwise it will go to the else part, that returns "false".  
5 0
3 years ago
4. 15 Exact change (College level not sure why it says middle school)
sweet [91]

Answer:

def print_change(total_change):#this is also total cents, because integers don't have decimal points, so I can't use dollars as my unit

dollars = int(total_change / 100)

remaining_change = total_change - dollars * 100

quarters = int(remaining_change / 25)

remaining_change -= quarters * 25

dimes = int(remaining_change / 10)

remaining_change -= dimes * 10

nickels = int(remaining_change / 5)

remaining_change -= nickels * 5

pennies = remaining_change

all = {'dollar': dollars, 'quarter': quarters, 'dime': dimes, 'nickel': nickels, 'penny': pennies}

for num in [0, 1, 2, 3, 4]:

coin_type = list(all.keys())[num]

amount = all[coin_type]

if num < 4 and amount > 1 or amount == 0 and num < 4:

coin_type += 's'

elif num == 4 and amount > 1 or amount == 0 and num == 4:

coin_type = 'pennies'

print('\n', amount, coin_type)

while True:

total_change = int(input()) #in cents

print_change(total_change)

Had fun making this one... hope it helps. :)

6 0
3 years ago
Other questions:
  • Using the syntax in section 2.3, write a command delete_all_rights (p, q, s). this command causes p to delete all rights the sub
    13·1 answer
  • rob just got a new idea for the movie he's making, and he wants to put in late hours to get it done. Which of the following stat
    10·1 answer
  • Which situation is an example of? "relational context" in the transactional model of? communication?
    12·1 answer
  • ____ is a special type of large, integrated system that ties together all types of a company’s activities, such as planning, man
    11·2 answers
  • What is the symbol for the relational operator 'equal to'?
    8·1 answer
  • Which one of the following business names would be rated Incorrect for name accuracy? Answer McDonald's McDonald's H&amp;M McDon
    14·1 answer
  • 4. An abstract data type is defined as _____.
    14·1 answer
  • Why is it difficult to convince top management to commit funds to develop and implement a Strategic Information System
    13·1 answer
  • The Bradshaw family has $200,000 of total assets and $140,000 of liabilities. What is their net worth?
    15·1 answer
  • Sftp uses which mechanism to provide security for authentication and data transfer?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!