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
The way a particular application views the data from the database that the application uses is a.
masha68 [24]

The way a particular application views the data from the database that the application uses is a sub-schema.

<h3>What is Database?</h3>

A Database may be defined as a process of collecting data and information that is principally assembled for quick search and recoupment by a computer.

The sub-schema is the reasoning elucidation of that section of the database which is applicable and accessible to a specific application. This type of database is common to two or more applications.

Therefore, the sub-schema is the way through which a particular application views the data from the database that the application uses.

To learn more about Database, refer to the link:

brainly.com/question/26096799

#SPJ4

4 0
2 years ago
After establishing a long term goal and understanding what it entails, the best next step is
Aleks [24]

Answer:

plan numerous intermediate short-term goals.

Explanation:

8 0
3 years ago
One suggested means of gaining eye contact before reversing is to:____.
Orlov [11]

Answer:

<u>hit the vehicle horn</u>

<u>Explanation:</u>

Remember, a driver reversing may easily go unnoticed by pedestrians as the driver may be coming from behind. Thus, a suggested means of gaining the eye contact of pedestrians before reversing is to hit the vehicle horn.

5 0
3 years ago
Which command shows the recommended way to display information about the network interface as well as its ip configuration?
tensa zangetsu [6.8K]
The "ipconfig" command in windows will show the configuration of all attached network interfaces.
7 0
3 years ago
Predictive Algorithms Identify one use/application in which tprediction might cause significant ethical harms.
horrorfan [7]
I do believe this would be true.
4 0
3 years ago
Other questions:
  • The operating system is not directly involved in one of these tasks.Immersive Reader
    12·1 answer
  • Ninety-two percent of the new information was stored on magnetic media, mostly in _____.
    11·1 answer
  • C++ Question: what is in the blanks?
    5·1 answer
  • Samuel is working on decimal and binary conversion for his college project. He is using the binary number 111011 and wants to ex
    10·2 answers
  • What is the output of the following program?
    9·1 answer
  • If a 9V, 7W radio is on from 9am to 12pm. Calculate the amount of charge that flows through it, hence or otherwise the total num
    8·1 answer
  • Consider the following code:
    6·1 answer
  • An employee of a large corporation remotely logs into the company using the appropriate username and password. The employee is a
    10·1 answer
  • Write short notes on the following:<br>I. keyboard ii.Control unit iii.printer​
    7·1 answer
  • which of the following statements about the evolving relationship between traditional newspaper operations and blogging is true?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!