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]
2 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]2 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
Assume that ip has been declared to be a pointer to int and that result has been declared to be an array of 100 elements . Assum
Bogdan [553]

Answer:

The expression of this question can be given as:

Expression:

*ip + 1

Explanation:

In this question, it is given that ip variable has been declared and initialized and the ip variable is in the first half of the array. It finds the expression whose value is after the element of the array that ip points. So the expression to this question is *ip + 1. Where * is used to define ip variable as a pointer and its value is increased by 1 that is given in the question.

7 0
3 years ago
, , ,g d,t ,dt m,dt ymtd
maks197457 [2]

Answer:ummm me confused

Explanation:

4 0
3 years ago
Consider the folloeing website URL:http://www.briannasblog.com. What does the "http://" represent?
Alex Ar [27]

i believe the answer would be (A) because HTTPS stands for Hypertext Transfer Protocol


6 0
2 years ago
Virtualization, like cloud computing, is a technology that can be useful for _____ sites. hot warm business cold
natima [27]

Answer: Hot sites

Explanation:

 Virtualization in the cloud computing is the technology that are useful for the hot sites. It basically making the virtual image of the network devices so that it can be easily use multiple machine at the similar time.

There are various types of benefits of the virtualization in the cloud computing are as follow:

  • It protect the system from the system failure.
  • It is the cost effective technology.
  • By using this we can easily transfer the data from the physical storage to the virtual server.
8 0
3 years ago
____ is a limited version of windows that allows you to use your mouse, screen, and keyboard but no other peripheral devices.
Gnoma [55]
'SAFEMODE' <span>is a limited version of windows that allows you to use your mouse, screen, and keyboard but no other peripheral devices.</span>
8 0
2 years ago
Other questions:
  • PPPLLLLEEEEAAASSSSEEEEE HHELLP me.Does anyone know how to copy an image onto a thing so i can post a real question on brainly. b
    8·2 answers
  • How to reply to text from unknown number?
    11·1 answer
  • A keyboard and touch screen are the most common of ________ devices. select one:
    11·1 answer
  • The monkey-and-bananas problem is faced by a monkey in a laboratory with some bananas hanging out of reach from the ceiling. A b
    8·1 answer
  • The CMOS battery located on a computer's motherboard allows for maintaining the correct time and date information stored in CMOS
    7·1 answer
  • A(n) __________ port, also known as a monitoring port, is a specially configured connection on a network device that is capable
    13·1 answer
  • Stuart wants to delete some text from a slide. What should Stuart do?
    8·1 answer
  • Fill in the blanks:
    15·1 answer
  • ________________, _______________ and ___________ are what you see when you open Excel
    14·2 answers
  • Windows is a GUI Operating System, what is the other type?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!