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
What is conference proceeding​
Archy [21]

Answer:

conference proceeding is a collection of academic papers published in the context of an academic conference or workshop.

3 0
3 years ago
Read 2 more answers
Pls help now the question is very hard someone help me pls​
satela [25.4K]

Answer:

The answers are "Option a, Option b, Option d, and Option c".

Explanation:

  • The Traceroute utilizes the "Internet Control Message Protocol" for transmit and receive echo-request and echo-reply messages. This is most often used in the echo packets of specified interval to live (TTL) quantities.
  • The Transport layer will be the next but is usually directly linked with the same name layer in the OSI model. Functions involve message fragmentation, acknowledgment, traffic management, session parallelization, error detection, as well as message rearranging.
  • Leaders generally fully involve one or even more workers in design buildings.
  • 67 was its UDP port number which is used as the port number of a database. So although UDP port number 68 is being used by the client.
4 0
3 years ago
The numbers on the bottom of a typical check represent all of the following EXCEPT
Phantasy [73]
<span>These numbers indicate the account a check is drawn on and from which bank.</span>
5 0
3 years ago
3. Megan and her brother Marco have a side business where they shop at flea markets, garage sales, and estate
Neko [114]

Answer:

a

Explanation:

Megan doesn't have a registered business. She can't claim insurance

4 0
3 years ago
Which of the following is based on the visibility and location of an object’s features?
grandymaker [24]

Answer:

The answer is Lines.

Explanation:

A visible line, or object line is a thick continuous line, used to outline the visible edges or contours of an object. A hidden line, also known as a hidden object line is a medium weight line, made of short dashes about 1/8” long with 1/16”gaps, to show edges, surfaces and corners which cannot be seen.

7 0
3 years ago
Other questions:
  • If your BAL is .10 you can expect a _______ drop in complex performance compared to the sober level
    6·1 answer
  • Explicit knowledge can be documented and codified, whereas tacit knowledge encompasses insights, judgment, creative processes, a
    9·1 answer
  • Which disc store compacity for full lenght movie? dvd or cd
    14·1 answer
  • Johnathan was assigned to complete a project with three other people. What benefit will he get from working with the team?
    15·1 answer
  • A letter of application should be written on:
    13·1 answer
  • In a paragraph, describe in detail a practical real-world example of where you would implement a singly-linked list and why a si
    8·1 answer
  • Select the correct answer from each drop-down menu. What are the effects of emerging technology? has brought the internet to alm
    10·1 answer
  • Which of the following lines of code correctly defines a function called combine? OA define "combine(a, b, c)" as: B. define(com
    9·1 answer
  • Which field would best function as a primary key for a table that tracks orders?
    11·2 answers
  • One of the benefits of holding an investment for over a year rather than selling it in less than a year is that the
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!