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 process combines data from a list with the content of a document to provide personalized documents?
Andrej [43]
The appropriate answer is d. mail merge. Mail merge uses a database of addresses that are used to create pre-addressed mailing labels that are generally used when sending letters to a very large group. This type of application is used by utility companies or any other organizations that requires mass mailings. Mail merge is found in the Microsoft Word application. Excell spreadsheets can also be used to complete tasks similar to that of mail merge.
8 0
2 years ago
Read 2 more answers
I don't understand how to write both. If I repeat the first code but with 3 and 6 it doesn't work.
hram777 [196]

It looks like you need to get both numbers from the input. Try doing something like this:

print(int(input()) + int(input()))

4 0
2 years ago
Floating point values (real numbers that can handle up to 5 decimals)
Ann [662]

Answer:

1.45638

Explanation:

p please mark me as brainlest

4 0
2 years ago
. What is an APT? What are some practical strategies to protect yourself from an APT?
viva [34]

Answer and Explanation:

Advanced Persistent Threat abbreviated as APT is a type of cyber attack which gives access to the unauthorized user  to enter the network without being detected for a long period.

APTs are generally sponsored by the government agencies of the nation or large firms. For example, one of the ATPs used was Stuxnet in the year 2010 against Iran, in order to put off the nuclear program of Iran.

Some of the practical strategies for protection against APT are:

  • Sound Internal Auditing
  • Strong Password Accessing Policies
  • Stringent policies for accessing any device
  • Introduction and implementation of multi factor authentication
  • Strong IDs and sound honeypot solutions
3 0
3 years ago
Explain how you would assess the operating system requirements for virtualization if the organization wanted to virtualize 25% o
insens350 [35]

Answer:

The requirement of the virtualization in the operating system:

• The virtualization of the resources from single systems input can be partitioned into a small virtual environment in multiple system data processes.

• Virtualization can collect the physical system's hardware and software data, they can transfer the virtualization process and also verify that the working system is running properly.

• Virtualization has to determine the specific components such as workload, file location, network traffic and console administration process. The requirement for moving into the virtual environment must be selected based on windows for the operating system(32-bit), windows host operating system(4-bit) and Linux operating system.

7 0
3 years ago
Other questions:
  • Why do computers need to periodically check the dns for websites you have already visited? enter your answer here?
    15·1 answer
  • Positive thinkers tend to
    9·2 answers
  • Sarah is creating and formatting a newsletter for her school. Which page layout rules should she consider when doing this?
    13·2 answers
  • What is the decimal number 75 in binary and hexadecimal?
    8·1 answer
  • True or false? Main Content (MC) may include links on the page.
    6·1 answer
  • Could this be restored? And is it worth the money it’d take?
    9·2 answers
  • I Just Realized................
    7·2 answers
  • Your school has been declared a school of technology
    15·1 answer
  • __________ are hosted on dedicated computers known as 'web servers'.​
    8·2 answers
  • Debug the recursive reverseString method, which is intended to return the input String str reversed (i.e. the same characters bu
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!