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
leonid [27]
3 years ago
15

Write a second constructor as indicated. Sample output: User1: Minutes: 0, Messages: 0 User2: Minutes: 1000, Messages: 5000

Computers and Technology
1 answer:
Mashcka [7]3 years ago
6 0

Complete Question:

Write a second constructor as indicated. Sample output:User1: Minutes: 0, Messages: 0User2: Minutes: 1000, Messages: 5000// ===== Code from file PhonePlan.java =====public class PhonePlan { private int freeMinutes; private int freeMessages; public PhonePlan() { freeMinutes = 0; freeMessages = 0; } // FIXME: Create a second constructor with numMinutes and numMessages parameters. /* Your solution goes here */ public void print() { System.out.println("Minutes: " + freeMinutes + ", Messages: " + freeMessages); return; }}

Answer:

The second constructor is given as:

//This defines the constructor, the name has to be the same as the class //name

PhonePlan(int numOfMinutes, int numberOfMessages) {

this.freeMinutes = numOfMinutes;

this.freeMessages = numberOfMessages

}

Explanation:

The second constructor is defined using java programming language.

  1. The given class has two constructors This is called "Constructor Overloading) which implements polymophism
  2. In the second constructor that we created, we pass in two arguments of type integer numOfMinutes and numberOfMessages.
  3. In the constructor's body we assign these values to the initially declared variables freeMinutes and freeMessages
You might be interested in
Create a list of strings based on a list of numbers The rules:_______
Delicious77 [7]

Answer:

listNumbers = [34,56,23,56,78,89,98,45,34,33,25,26,67,78]

listString = [ ]

for i in range(14):

   if listNumbers[i]%2!=0 and listNumbers[i]%5==0:

       listString.append("five odd")

   elif listNumbers[i]%5==0 and listNumbers[i]%2==0:

       listString.append("five even")

   elif listNumbers[i]%2==0:

       listString.append("even")

   elif listNumbers[i]%2!=0:

       listString.append("odd")

print(listNumbers)

print(listString)

Explanation:

In python programming language;

  1. Create two lists
  2. The first is a list of numbers and initialize it with random values: listNumbers = [34,56,23,56,78,89,98,45,34,33,25,26,67,78]
  3. The second list is empty and will hold the string values listString = [ ]
  4. Use a for loop to iterate over all the elementts in the list of numbers
  5. Use the modulo operator (%) to chech for multiples of particular numbers as stipulated by the question
  6. Use combination of if/elif statements for each condition
  7. Use the .append method to add the elements into the list of strings
  8. finially output both lists

See attached code and output

3 0
3 years ago
236. A system such as a printer, smart TV, or HVAC controller, typically uses an operating system on what is called a:
irakobra [83]

Answer:

Embedded System

5 0
2 years ago
Read 2 more answers
_____ (without parity) means spreading the data among multiple (at least two) drives. Group of answer choices Parity
Llana [10]

Answer:

"Disk Striping" would be the right choice.

Explanation:

  • Disk stripping has become a methodology where certain numerous small external drives consist of a single massive disk. This same classification turns huge information into single blocks but instead disperses them over numerous different storage media.
  • Disk stripping retail outlets instead of every data unit through a single place and doesn't provide disk failure safeguards.
3 0
3 years ago
What are the core components of a computer system? CPU, RAM, ROM, I/O ports, keyboard CPU, RAM, ROM, I/O ports, system bus CPU,
zimovet [89]
CPU, RAM, ROM, system bus, I/O ports
8 0
4 years ago
Read 2 more answers
Write a program that takes three numbers as input from the user, and prints the largest.
S_A_V [24]

Answer:

In Python:

n1 = int(input("Enter a number: "))

n2 = int(input("Enter a number: "))

n3 = int(input("Enter a number: "))

if n1 >= n2 and n1 >= n3:

   print("Largest: "+str(n1))

elif n2 >= n1 and n2 >= n3:

   print("Largest: "+str(n2))

else:

   print("Largest: "+str(n3))

Explanation:

The next three lines get three numbers from the user

n1 = int(input("Enter a number: "))

n2 = int(input("Enter a number: "))

n3 = int(input("Enter a number: "))

This checks if the first number is greater than the other two. If yes, the first number is printed as the largest

<em>if n1 >= n2 and n1 >= n3:</em>

<em>    print("Largest: "+str(n1))</em>

This checks if the second number is greater than the other two. If yes, the second number is printed as the largest

<em>elif n2 >= n1 and n2 >= n3:</em>

<em>    print("Largest: "+str(n2))</em>

This prints the third number as the largest, if the other two conditions fail

else:

   print("Largest: "+str(n3))

3 0
3 years ago
Read 2 more answers
Other questions:
  • David has a laptop that is having a problem with the video system. You believe the problem might be the backlight. During your r
    13·1 answer
  • Which statement about UML class diagrams is true?
    8·1 answer
  • What the repeal of online privacy protections means for you?
    8·1 answer
  • What is a Slide Master?
    14·2 answers
  • The company currently runs 60 autonomous APs and has plans to increase wireless density by 50% in the near future
    13·1 answer
  • . In many instances an IP address is used to access a server rather than a URL because a URL is more difficult to set up and eas
    10·1 answer
  • Write a Bash script that takes the name of a file or directory as an argument, 1. reports if it is a directory or a file, and if
    14·1 answer
  • I found a brand-new charger wire still in its plastic package, but it's six years old and has never been used. Is it safe to use
    9·1 answer
  • What are the steps in preparing a bootable USB installer?​
    11·1 answer
  • How to write my name in binary code ? Rivas
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!