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
aleksley [76]
2 years ago
9

Have the javascript function CountingMinutes(str) take the str parameter being passed which will be two times (each properly for

matted with a colon and am or pm) separated by a hyphen and return the total number of minutes between the two times. The time will be in a 12 hour clock format. For example: if str is 9:00am-10:00am then the output should be 60. If str is 1:00pm-11:00am the output should be 1320.
function CountingMinutes(str) {
// code goes here
return str;
}
// keep this function call here
console.log(CountingMinutes(readline()));
Computers and Technology
1 answer:
jarptica [38.1K]2 years ago
5 0

Using the knowledge in computational language in Java it is possible to write a code that function as CountingMinutes:

<h3>Writing the code in Java:</h3>

function CountingMinutes(str) {

     // code goes here  

     // Declare variables for calculating difference in minutes

     // variables in JavaScript are declared with "let" keyword

     /* Build regelar expression which will match the pattern of "12houttime-12hourtime"

        and extract time or hours in numbers from it */

     let extractedTimeStringArray = str.match(/(\d+)\:(\d+)(\w+)-(\d+)\:(\d+)(\w+)/);

     // extractedTimeStringArray array will be like- ["1:00pm-11:00am", "1", "00", "pm", "11", "00", "am", index: 0, input: "1:00pm-11:00am", groups: undefined]    for str = "1:00pm-11:00am"

     // console.log('object', time)

     

     // Extract array value at 1st index for getting first time's hours (ie time before hyphen like 1:00pm in 1:00pm-11:00am )  (like 11 from 11:32am) and convert them to minutes by multiplying by 60

     let mintsOfFirstTimeFromHours = extractedTimeStringArray[1] * 60;

     // Extract array value at 2nd index for getting first time's minutes like 32 from 11:32am

     let mintsOfFirstTimeFromMints = extractedTimeStringArray[2];

     // Extract array value at 4th index for getting second time's hours (ie time after hyphen like 11:00am in 1:00pm-11:00am ) and convert them to minutes by multiplying by 60

     let mintsOfSecondTimeFromHours = extractedTimeStringArray[4] * 60;

     // Extract array value at 5th index for getting second time's minutes like 32 from 11:32am

     let mintsOfSecondTimeFromMints = extractedTimeStringArray[5];

     // if second time's 12 hour time is in pm

     if (extractedTimeStringArray[6] === "pm") {

       // Add 12 * 60 = 720 minutes for 12 hrs

         mintsOfSecondTimeFromHours += 720;

     }

     // if first time's 12 hour time is in pm

     if (extractedTimeStringArray[3] === "pm") {

        // Add 12 * 60 = 720 minutes for 12 hrs to first time

       mintsOfFirstTimeFromHours += 720;

        // Add 12 * 60 *2 = 1440 minutes for 24 hrs to second time

       mintsOfSecondTimeFromHours += 1440;

     }

     // Calculate output minutes difference between two times separated by hyphen

    str = (mintsOfSecondTimeFromHours - mintsOfFirstTimeFromHours) + (mintsOfSecondTimeFromMints - mintsOfFirstTimeFromMints);

     // return calculated minutes difference

     return str;

   }

   // keep this function call here

   // call the function and console log the result

   console.log(CountingMinutes("1:00pm-11:00am"));

   // output in console will be-  1320

See more about Java at: brainly.com/question/12975450

#SPJ1

You might be interested in
If a preferred (faster) learned route over a WAN has administrative distance 110 that competes with a static backup (slower) rou
almond37 [142]

The engineer will need to set the distance to 130 for the static link so that it becomes a floating static route.

<h3>What is Floating static routes?</h3>

This is known to be a static routes that is said to have a kind of administrative distance that is also known to be bigger than the administrative distance of any other static route or dynamic routes.

Note that the value 130 stands for the next most logical value, nd as such it is to know that the right route comes first in the steps for administrative distance.

Learn more about WAN from

brainly.com/question/11352260

5 0
2 years ago
In a C++ program, one and two are double variables and input values are 10.5 and 30.6. After the statement cin &gt;&gt; one &gt;
SSSSS [86.1K]

Answer:

variable one stores 10.5 and two stores 30.6

Explanation:

In c++ language, the cout keyword is used to write to the standard output. The input from the user is taken by using the cin keyword.

For the input from the user, a variable need is declared first.

datatype variable_name;

The input can be taken one at a time as shown.

cin >> variable_name;

The input for more than one variable can be taken in a single line as given by the syntax below.

1. First, two variables are declared.

datatype variable_name1, variable_name2;

2. Both input is taken simultaneously as shown.

cin >> variable_name1, variable_name2;

For the given scenario, two double variables are declared as below.

double one, two;

The question mentions input values for the two double variables as 10.5 and 30.6.

3. The given scenario takes both the values as input at the same time, in a single line as shown below.

cin >> one >> two;

4. After this statement, both the values entered by the user are accepted.

The values should be separated by space.

First value is stored in the variable one.

Second value is stored in the variable two.

5. The user enters the values as follows.

10.5 30.6

6. The value 10.5 is stored in variable one.

7. The value 30.6 is stored in variable two.

The c++ program to implement the above is given below.

#include <iostream>

using namespace std;

int main() {

   double one, two;      

   cout << " Enter two decimal values " << endl;

   cin >> one >> two;

   cout << " The input values are " << endl;

   cout << " one : " << one << " \t " << " two : " << two << endl;

   return 0;

}

OUTPUT

Enter two decimal values  

10.5 30.6

The input values are  

one : 10    two : 530.6

6 0
3 years ago
Which description of the plain text file format is most accurate?
dsp73
1. uses binary code to store data!
4 0
3 years ago
Read 2 more answers
1. Explain what is meant by the following data types:
Colt1911 [192]
An Integer in an object that represent an int (Integer a = new Integer(3) would represent 3).

I'm not sure about Real.

A String is an object that represents a word. (String a = "dog")

Boolean

String

int

int

Hope this kind of helps
4 0
3 years ago
8. Explain what the following spredications of a monitor refer to their significance for the user and how
Maslowich

Answer:

A computer monitor is an output device that displays information in pictorial form. A monitor usually comprises the visual display, circuitry, casing, and power supply. The display device in modern monitors is typically a thin film transistor liquid crystal display (TFT-LCD) with LED backlighting having replaced cold-cathode fluorescent lamp (CCFL) backlighting. Previous monitors used a cathode ray tube (CRT). Monitors are connected to the computer via VGA, Digital Visual Interface (DVI), HDMI, DisplayPort, USB-C, low-voltage differential signaling (LVDS) or other proprietary connectors and signals.

Originally, computer monitors were used for data processing while television sets were used for entertainment. From the 1980s onwards, computers (and their monitors) have been used for both data processing and entertainment, while televisions have implemented some computer functionality. The common aspect ratio of televisions, and computer monitors, has changed from 4:3 to 16:10, to 16:9.

Modern computer monitors are easily interchangeable with conventional television sets and vice versa. However, as computer monitors do not necessarily include integrated speakers nor TV tuners (such as Digital television adapters), it may not be possible to use a computer monitor as a TV set without external components.[1]

History

Early electronic computers were fitted with a panel of light bulbs where the state of each particular bulb would indicate the on/off state of a particular register bit inside the computer. This allowed the engineers operating the computer to monitor the internal state of the machine, so this panel of lights came to be known as the 'monitor'. As early monitors were only capable of displaying a very limited amount of information and were very transient, they were rarely considered for program output. Instead, a line printer was the primary output device, while the monitor was limited to keeping track of the program's operation.[2]

Computer monitors were formerly known as visual display units (VDU), but this term had mostly fallen out of use by the 1990s.

Technologies

Further information: Comparison of CRT, LCD, Plasma, and OLED and History of display technology

Multiple technologies have been used for computer monitors. Until the 21st century most used cathode ray tubes but they have largely been superseded by LCD monitors.

Cathode ray tube

Main article: Cathode ray tube

The first computer monitors used cathode ray tubes (CRTs). Prior to the advent of home computers in the late 1970s, it was common for a video display terminal (VDT) using a CRT to be physically integrated with a keyboard and other components of the system in a single large chassis. The display was monochrome and far less sharp and detailed than on a modern flat-panel monitor, necessitating the use of relatively large text and severely limiting the amount of information that could be displayed at one time. High-resolution CRT displays were developed for the specialized military, industrial and scientific applications but they were far too costly for general use.

Some of the earliest home computers (such as the TRS-80 and Commodore PET) were limited to monochrome CRT displays, but color display capability was already a standard feature of the pioneering Apple II, introduced in 1977, and the speciality of the more graphically sophisticated Atari 800, introduced in 1979. Either computer could be connected to the antenna terminals of an ordinary color TV set or used with a purpose-made CRT color monitor for optimum resolution and color quality. Lagging several years behind, in 1981 IBM introduced the Color Graphics Adapter, which could display four colors with a resolution of 320 × 200 pixels, or it could produce 640 × 200 pixels with two colors. In 1984 IBM introduced the Enhanced Graphics Adapter which was capable of producing 16 colors and had a resolution of 640 × 350.[3]

By the end of the 1980s color CRT monitors that could clearly display 1024 × 768 pixels were widely available and increasingly affordable. During the following decade, maximum display resolutions gradually increased and prices continued to fall. CRT technology remained dominant in the PC monitor market into the new millennium partly because it was cheaper to produce and offered to view angles close to 180°.[4] CRTs still offer some image quality advantages[clarification needed] over LCDs but improvements to the latter have made them much less obvious. The dynamic range of early LCD panels was very poor, and although text and other motionless graphics were sharper than on a CRT, an LCD characteristic known as pixel lag caused moving graphics to appear noticeably smeared and blurry.

Explanation:

8 0
2 years ago
Other questions:
  • A(n) ____ is a collection of one or more program statements combined to perform some action
    14·1 answer
  • How long does a baby dolphin stay with its mum
    8·1 answer
  • Where can you find your EFC
    8·2 answers
  • Hypercompetition implies that any architecture must be designed with maximum flexibility and _____ to ensure it can handle the i
    6·1 answer
  • The best way to safeguard your document is to save it
    11·1 answer
  • On start up, which of these windows is not displayed ?
    15·2 answers
  • List and explain three computing devices from the 20th century​
    13·2 answers
  • Define a function FindLargestNum() with no parameters that reads integers from input until a negative integer is read. The funct
    9·1 answer
  • Finish the format string to get the output shown below.<br> Day<br> &gt;&gt;&gt;{ v8'_format('Day)
    5·1 answer
  • Hey there! What would be the best way for me to learn Lua script? As well as learn Data Store, and other stuff. Thanks! Brainly
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!