answer.
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]
2 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]2 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
Exercise 3: Function Write a function named word_count that accepts a string as its parameter and returns the number of words in
Kryger [21]

Answer:

I am writing a PHP program.

<?php  

function word_count($string){   // function that takes a string a parameter and returns the number of words in that string

  $space = 0;   // this variable is used in order to detect space, new line and tab spaces in a string

  $words = 1; // this variable is used to identify word presence in string

  $include = $space;  //used to maintain the state of $words and $space

  $counter = 0; // this counts the number of words in the string

  $i = 0; //this moves through each character of the string

  while ($i < strlen($string)){ // iterates through every character of string until the last character of string is reached

      if ($string[$i] == " "||$string[$i] == "\n" || $string[$i] == "\t")  //if the space or new line or tab space is identified in the string

          $include = $space; //set the state of include as space if the next character is a space newline or a tab space

      else if ($include == $space) {  //if next character is a word and current state i.e. $include holds $space

          $include = $words;   //  then set the state i.e. $include as $words

          ++$counter; } //increments i to move to next character at each iteration

      ++$i;  } //returns the number of words in a string

  return $counter; }

$str = "Hello, how are you ";  //sample string

echo "Words: " . word_count($str);  // calls word_count function to return number of words in str.

?>  

Explanation:

The program has a function word_count that accepts a string as its parameter and returns the number of words in the string. In the function there are three variables $space and $words and $include used as state variables. For instance $space identifies space, new line and tab spaces in the $string so it specifies that a space has occurred. $words identifies words in the $string so it specifies that a word has occurred. $include holds this state information. $i moves through every character of the $string and when a space occurs in the $string then the state $include is set to $space. When a word occurs then state $include is set to $words. $counter variable, which is used to count the number of words is incremented to 1 when previous state is $space and next character is a word character. Every time a word is seen in the string, this variable is incremented to 1 to keep track of number of words in the string. When $i reaches the end of the string then this loop stops and counter returns the number of words in the $string.

8 0
1 year ago
john wants to view sarah's assignment files on his computer. but he cannot open them because of version problems. which upgrade
weqwewe [10]
He's need to restart his computer, because the computer have some glitches or virus.
4 0
2 years ago
Read 2 more answers
As an information user you should be skeptical of
Sati [7]
I should be skeptical of the credibility of sources that I have during the gathering. Be cautious and make sure that data comes of from trusted specialized sources. Trusted sources can be easily identified for their popularity on certain fields. Determine the purpose of the site and the data it contains.
5 0
2 years ago
A small e-commerce company uses a series of Robotic Process Automation solutions to manage the backup of data from individual wo
Vaselesa [24]

Answer:

Cloud.

Explanation:

Cloud computing can be defined as a form of data computing which requires the use of shared computing resources such as cloud storage (data storage), servers, computer power, and software over the internet rather than local servers and hard drives.

Generally, cloud computing offer individuals and businesses a fast, secured, effective and efficient way of providing services over the internet.

Basically, cloud computing comprises three (3) service models and these include;

1. Platform as a Service (PaaS).

2. Software as a Service (SaaS).

3. Infrastructure as a Service (IaaS).

Additionally, the two (2) main characteristics of cloud computing are;

I. Measured service: it allows cloud service providers to monitor and measure the level of service used by various clients with respect to subscriptions.

II. Resource pooling: this allows cloud service providers to serve multiple customers or clients with services that are scalable and provisional.

For example, the provisioning of On-demand computing resources such as storage, network, virtual machines (VMs), etc., so as to enable the end users install various software applications, database and servers.

Hence, the technology that could be combined by the small e-commerce company with its current automated processes is cloud storage.

9 0
1 year ago
Show how to define a view tot_credits (year, num_credits), giving the total number of credits taken by students in each year
andreev551 [17]

Hi! I'm a Digital Marketer Intern at hotels.ng and I have a moderate knowledge on programming.

First, your  question is not very explanatory. The term "view" is often used in back-end web development. A view is simply a Python function that takes a Web request and returns a Web response.

But I'm not sure this is what you want, so I'll just go ahead and write a python function involving class to return the total number of credits taken by a student.

I'll answer this question using Python.

class student(object):  

    credits = None

    year = None

    def num_credits(self):


       #get credit value

       self.credits = input("Enter the total number of credits: "  )


       pass

    def getYear(self):

        self.year = input("Enter current year: ")

        pass

    def tot_credits(self):

          TotalCredits = tempTotalCredits + self.num_credits

           print "Your  total credits are :"+" "+str(TotalCredits)




3 0
2 years ago
Other questions:
  • Where is the Name Manager dialog box found?
    13·1 answer
  • Steps in creating a folder
    12·1 answer
  • The final step of the DHCP Discovery process is known as ______.
    5·1 answer
  • You have installed a point-to-point connection using wireless bridges and Omni directional antennas between two buildings. The t
    9·1 answer
  • A company operates on two types of servers: 2 large servers (L) and 4 smaller servers (S), with a combined total of 64GB RAM. Th
    9·1 answer
  • Item = "quesadilla"
    7·1 answer
  • Write a script that prints the multiples of 7 between 0 and 100. Print one multiple per line and avoid printing any numbers that
    14·1 answer
  • Write a loop that continually asks the user what pets the user has, until the user enters "rock", in which case the loop ends. I
    12·1 answer
  • Cardinality ratios often dictate the detailed design of a database. The cardinality ratio depends on the real-world meaning of t
    8·1 answer
  • Plz help code practice for python
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!