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

9.18 LAB: Exact change - methods Write a program with total change amount as an integer input that outputs the change using the

fewest coins, one coin type per line. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. Ex: If the input is:
Computers and Technology
1 answer:
Sedbober [7]3 years ago
6 0

Answer:

Explanation:

The following code is written in Java. It asks the user to enter the amount of change needed. This is done as a double since we are dealing with coins and not full dollar values alone. It then makes the necessary calculations to calculate the number of each coin needed and outputs it back to the user. A test case has been provided in the picture below with a sample output.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       int dollars = 1;

       double quarters = 0.25;

       double dimes = 0.10;

       double nickels = 0.05;

       double pennies = 0.01;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Change Value: ");

       double change = in.nextDouble();

       int numDollars, numQuarters, numDimes, numNickels, numPennies;

       double newChange;

       numDollars = (int) (change / dollars);

       newChange = change % dollars;

       numQuarters = (int) (newChange / quarters);

       newChange = newChange % quarters;

       numDimes = (int) (newChange / dimes);

       newChange = newChange % dimes;

       numNickels = (int) (newChange / nickels);

       newChange = newChange % nickels + 0.001;

       numPennies = (int) (newChange / pennies);

       newChange = newChange % pennies;

       

       System.out.println("Minimum Num of Coins needed: ");

       if (numDollars != 1) {

           System.out.println(numDollars + " Dollars");

       } else {

           System.out.println(numDollars + " Dollar");

       }

       if (numQuarters != 1) {

           System.out.println(numQuarters + " Quarters");

       } else {

           System.out.println(numQuarters + " Quarter");

       }

       if (numDimes != 1) {

           System.out.println(numDimes + " Dimes");

       } else {

           System.out.println(numDimes + " Dime");

       }

       if (numNickels != 1) {

           System.out.println(numNickels + " Nickels");

       } else {

           System.out.println(numNickels + " Nickel");

       }

       if (numPennies != 1) {

           System.out.println(numPennies + " Pennies");

       } else {

           System.out.println(numPennies + " Penny");

       }

   }

}

You might be interested in
What is the function of Cascading Style Sheets?
Kaylis [27]

Answer:

answer is c

Explanation:

no need for explaination

8 0
3 years ago
What is basically the only thing that computers (microprocessors and prgrammable devices) understand?
horsena [70]

Answer:

Binary Code

Explanation:

All microprocessors and programmable devices understand is Binary Code. These are various combinations of 0's and 1's which when placed together in a sequence represent a set of instructions that the microprocessor can read and understand to complete complex tasks. There are various other programming languages to program these tasks in an easier to read syntax for the programmers themselves but they simply take the written code and convert it into Binary before sending it to the microprocessor.

4 0
3 years ago
how can cindy collaborate with mallory in order for cindy to be able to decrypt all subsequent encrypted messages that are sent
Olenka [21]

Cryptography, like digital signatures, is used to accomplish nonrepudiation, which also includes services for authentication, auditing, and logging.

Digital signatures in online transactions make assurance that a party cannot later dispute the sending of information or the validity of its signature. Alice can encrypt the communication using her own Private Key. As a result, only her public key, which she is aware Bob (and everyone else) has access to, may be used to decrypt her message. Bob receives the message, and he uses Alice's public key to decrypt it. Secret key cryptography (symmetric encryption): To encrypt and decrypt given messages, both the sender and the receiver must use the same key.

Learn more about information here-

brainly.com/question/15709585

#SPJ4

6 0
1 year ago
What feature allows you to access previous copies of a document on OneDrive?
swat32
<span>C) Stored work

I hope this helps :)
</span>
4 0
3 years ago
Read 2 more answers
State five benefits of digitizing data​
ddd [48]

Answer:

Ahorro de espacio físico. ...

Protección de los datos. ...

Gestión del tiempo en la consulta de datos. ...

Mejora de la productividad. ...

Responsabilidad social corporativa. ...

Acceso a la información a través de distintos dispositivos tecnológicos.

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Of the different IRT roles, the _______________ is head of the team and issues the ultimate call regarding how to respond to an
    15·1 answer
  • Write a Tip Calculator in code in VMware Fusion
    13·1 answer
  • What is resource Management in Wireless Communication ? Explain its Advantages?
    6·1 answer
  • How a computer encodes text, how it is processed and how computer data is represented.
    6·1 answer
  • Consider the following recurrence, defined for n a power of 4 (for the time of some algorithm): T(n) = 3 if n = 1 2T(n/4) + 4n +
    10·1 answer
  • When would you include an executive summary in a report
    14·2 answers
  • What is the difference between PowerPoint and Outlook?
    5·1 answer
  • What is the console.log function for?​
    13·1 answer
  • Explain how AI smartphone software in the rental car can be a threat to privacy.
    14·1 answer
  • What type of task can be defined to allow you fine-grained control over the management tasks a user can perform in an OU
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!