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
BigorU [14]
3 years ago
11

Write a program name Dollars that calculates and displays the conversion of an entered number of dollars into currency denominat

ions---20s, 10s, 5s, and 1s.
Computers and Technology
1 answer:
Cloud [144]3 years ago
7 0

Answer:

I will code in Javascript.

Preconditions:

  • The variable dollar is passed by parameter to the function.

function Dollars(dollar) {

 

//declare and initialize the variables.

 var twenties = 0;

 var tens = 0;

 var fives = 0;

 var ones = 0;

 

<em>//If dollar is greater or equals 20, divide dollar by 20 and save it into the variable twenties. Then, save the remainder into the variable dollar.  </em>

 if(dollar >= 20){

   twenties = Math.floor(dollar/20);

   dollar = dollar % 20;

 }

<em>//If dollar is greater or equal 10, divide dollar by 10 and save it into the variable twenties. Then, save the remainder into the variable dollar.  </em>

 if(dollar>=10){

   tens = Math.floor(dollar/10);

   dollar = dollar % 10;

 }

<em>//If dollar is greater or equal 5, divide dollar by 5 and save it into the variable twenties. Then, save the remainder into the variable dollar.  </em>

 if(dollar>=5){

   fives = Math.floor(dollar/5);

   dollar = dollar % 5;

 }

<em> //If dollar is greater or equal 1, divide dollar by 1 and save it into the variable twenties. Then, save the remainder into the variable dollar.   </em>

 if(dollar>=1){

   ones = Math.floor(dollar/1);

   dollar = dollar % 1;

 }

//At this point, dollar is equal 0.It's time to display the conversion.

Console.log('20s :' + twenties);

Console.log('10s :' + tens);

Console.log('5s :' + fives);

Console.log('1s :' + ones);

}

Explanation:

The variable Math.floor(num) is used to round a number downward to its nearest integer.

For example, if dollar=57:

twenties = dollar/20 will be 57/20 = 2

dollar = dollar % 20 will be 57 % 20 = 17

tens = dollar/10 will be 17/10 = 1

dollar = dollar % 10 will be 17 % 10 = 7

fives = dollar/5 will be 7/5 = 1

dollar = dollar % 5 will be 7 % 5 = 2

ones = dollar/1 will be 2/1 = 2

dollar = dollar % 1 will be 0 % 5 = 0

You might be interested in
Please help! I need to submit this quick!
taurus [48]

Answer:

B, C, A

Explanation:

i think those are right

3 0
3 years ago
Read 2 more answers
Prior to the world wide web as we know it today, the internet was chaotic, without any ____.
atroni [7]
Search engines - there was no single way to ask a question
5 0
3 years ago
Protocols used in each layers in each osi reference model
natka813 [3]

The protocols  that are often used in each layers in each OSI reference model are:

Layers                           Protocols

Layer 7- Application          SMTP, HTTP, FTP, POP3, SNMP

Layer 6- Presentation           MPEG, ASCH, SSL, TLS

Layer 5-Session                   NetBIOS, SAP

Layer 4-Transport                      TCP, UDP

Layer 3-Network                IPV5, IPV6, ICMP, IPSEC, ARP, MPLS.

Layer 2-Data Link       RAPA, PPP, Frame Relay, ATM, Fiber Cable.

Layer 1-Physical              RS232, 100BaseTX, ISDN, 11.

<h3>What is OSI Model?</h3>

The OSI Model is known to be a kind of a logical and conceptual framework that tells all about network communication that is often used by systems in an open to interconnection and also in any communication with other forms of systems.

Note that the Open System Interconnection (OSI Model) is one that tells more about a logical network and it is one that also tells about computer packet transfer via the use of various layers of protocols.

Therefore, The protocols  that are often used in each layers in each OSI reference model are:

Layers                           Protocols

Layer 7- Application          SMTP, HTTP, FTP, POP3, SNMP

Layer 6- Presentation            MPEG, ASCH, SSL, TLS

Layer 5-Session                   NetBIOS, SAP

Layer 4-Transport                      TCP, UDP

Layer 3-Network                IPV5, IPV6, ICMP, IPSEC, ARP, MPLS.

Layer 2-Data Link       RAPA, PPP, Frame Relay, ATM, Fiber Cable.

Layer 1-Physical              RS232, 100BaseTX, ISDN, 11.

Learn more about OSI reference model  from

brainly.com/question/12976859

#SPJ1

8 0
1 year ago
How to change the indent of the list item "regular" on slide 2 to .5 inches in powerpoint?
galina1969 [7]
<span>You can change the identation of text in Powerpoint by right clicking on the list item and selecting, "Format Text". On the paragraph tab, you can adjust the indentation before text as given in inches.</span>
4 0
3 years ago
Please help, I can't find the answer but I understand the topic.
gladu [14]

Answer:

x=(2+3)*3;

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • The HR department of a company wants to send out an email informing its employees about an upcoming social event. Which email ap
    11·2 answers
  • What are the benefits of organizing your thoughts before you begin your speech
    14·1 answer
  • What are the coordinates of (3 comma space 8 )relative to the basis open curly brackets space (1 comma space 1 )comma space (0 c
    15·1 answer
  • Which of the following is a name for the place an information services and support professional might work? software development
    15·2 answers
  • Computers help eliminate that repetitive of manual task. How can this benefit you in in your overall career
    7·2 answers
  • Dynamic programming does not work if the subproblems: ___________
    5·1 answer
  • Identify the characteristics of logic problems. Select all that apply.
    11·2 answers
  • 9. Lael wants to determine several totals and averages for active students. In cell Q8, enter a formula using the COUNTIF functi
    9·1 answer
  • Group of programs are software <br>​
    11·1 answer
  • Please help with this question
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!