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
1.Which of the serves as the basis for determining whether an object has moved or not?
Harrizon [31]

Answer:

1. b

2. c

3. b

4. d

5. a

(hope this helped)

4 0
2 years ago
It is a single strand of metal capable of transmitting power or data from one area to<br> another
Lera25 [3.4K]

Answer: A wire

Explanation:

8 0
2 years ago
What were the important developments that occurred in photography that facilitated the creation of motion pictures? Two critical
8_murik_8 [283]

Answer:

"A moving picture is an illusion that makes a still photo seem to move. The basic principal behind motion pictures is the fast transition between one picture to the next, almost creating a seamless transition. A flip-book is a good example of this. Another example would be film used for old movies. The film contains negatives of an image which when light is shined through creates a "shadow" of the image. If you quickly transition the film from one image to the next you end up a motion picture."

Explanation:

7 0
2 years ago
Which of the following statements is false? Question 4 options: By convention class names begin with an uppercase letter, and me
amm1812

Answer:

Instance variables can be declared anywhere inside a class.

Although there isn't any rule to declare instance variables before methods, and they can be declared anywhere in the class, they cannot be declared inside method definitions of class.

///////////////////////////////////////////////////////////////////////////////////////////////////////////

<em>By convention class names begin with an uppercase letter, and method and variable names begin with a lowercase letter.</em> - True.

<em>Instance variables exist before methods are called on an object, while the methods are executing and after the methods complete execution.</em> - True.

<em>A class normally contains one or more methods that manipulate the instance variables that belong to particular objects of the class.</em> - True

8 0
3 years ago
Read 2 more answers
Simplify (6x+6)+(-3-4x) please hurry!!!!!
Ilia_Sergeevich [38]

Answer:

2x + 3

Explanation:

8 0
3 years ago
Other questions:
  • To clean dirt and spilled electrolyte from a battery, use a dilute solution of either water and baking soda or water and A. sulf
    13·1 answer
  • Write a Tip Calculator in code in VMware Fusion
    13·1 answer
  • What does "FDDI" stand for in Technology?
    5·2 answers
  • Book checkout scenario at a library: The Worker tells the System the identity of a patron who wishes to check out books. The Sys
    8·1 answer
  • Which kind of software allows users to draw pictures, shapes, and other graphical images with various on-screen tools such as a
    14·1 answer
  • When a diaphragm contracts, a person is<br>Exhaling<br>Inhaling​
    12·2 answers
  • Which part of the operating system enables you to interact with the device? Question 9 options: The graphical user interface The
    8·1 answer
  • Por favor alguem poderia me falar qual PC e melhor: Computador Gamer Fox PC FPS Intel Core i5 8GB (GeForce GTX 1050Ti 4GB GDDR5)
    15·1 answer
  • Match each item with a statement below. - A popular port scanners that has the ability to use a GUI front end - Allows you to pi
    8·1 answer
  • In design and implementation of any _____ reasoning application, there are 4 Rs involved: retrieve, reuse, revise, and retain.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!