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
Gnoma [55]
3 years ago
11

Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per li

ne. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. If the input is 0 or less, output: no change. If the input is 45, the output is:
1 quarter 2 dimes
Computers and Technology
1 answer:
Contact [7]3 years ago
3 0

Answer:

The program in python programming language is as follows

amount = int(input("Enter Amount:  "))

#Check if input is less than 1

if amount<=0:

     print("No Change")

else: #If otherwise

     #Convert amount to various coins

     dollar = int(amount/100) #Convert to dollar

     amount = amount % 100 #Get remainder after conversion

     quarter = int(amount/25) #Convert to quarters

     amount = amount % 25 #Get remainder after conversion

     dime = int(amount/10) #Convert to dimes

     amount = amount % 10 #Get remainder after conversion

     nickel = int(amount/5) #Convert to nickel

     penny = amount % 5 #Get remainder after conversion

     #Print results

     if dollar >= 1:

           if dollar == 1:

                 print(str(dollar)+" dollar")

           else:

                 print(str(dollar)+" dollars")

     if quarter >= 1:

           if quarter == 1:

                 print(str(quarter)+" quarter")

           else:

                 print(str(quarter)+" quarters")

     if dime >= 1:

           if dime == 1:

                 print(str(dime)+" dime")

           else:

                 print(str(dime)+" dimes")

     if nickel >= 1:

           if nickel == 1:

                 print(str(nickel)+" nickel")

           else:

                 print(str(nickel)+" nickels")

     if penny >= 1:

           if penny == 1:

                 print(str(penny)+" penny")

           else:

                 print(str(penny)+" pennies")

Explanation:

The program is written in python programming language and it uses comments to explain some lines

Variable amount is declared as integer

Line 3 checks if amount is less than or equal to 0

If yes, the program outputs No Change

Else, it converts the input amount to lesser coins

Line 7 of the program gets the dollar equivalent of the input amount

Line 8 gets the remainder

Line 9 gets the quarter equivalent of the remainder

Line 10 gets the remainder

Line 11 gets the dime equivalent of the remainder

Line 12 gets the remainder

Line 13 gets the nickel equivalent of the remainder

Line 14 gets the penny equivalent of the remainder

Line 16 till the end of the program prints the output and it uses appropriates name (singular and plural)

You might be interested in
Which of the following class definition defines a legal abstract class Group of answer choices public class Rectangle abstract {
valkas [14]
<h2>Question</h2>

Which of the following class definition defines a legal abstract class Group of answer choices

(a)

public class Rectangle abstract {

   public abstract double findArea ( );

   

}

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

   

}

(c)

public class Rectangle {

   public abstract double findArea ( );

   

}

(d)

public class abstract Rectangle {

   public abstract double findArea ( );

   

}

<h2>Answer:</h2>

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

}

<h2>Explanation:</h2>

When a class is declared with the abstract keyword, the class is called an abstract class. Abstract classes cannot be instantiated and may include one or more abstract methods. If a class contains an abstract method, then it (the class) must be declared abstract.

In Java, abstract classes are defined using the following format:

<em>[access_modifier]</em> abstract class <em>[name_of_class]</em>

[access_modifier] specifies the access modifier of the class which could be public, private, e.t.c

abstract is the keyword that specifies that the class is an abstract class.

class is a keyword used for defining classes

name_of_class specifies the name of the class.

The only option that fulfils this format is <em>option b</em> where;

(i) The access modifier is public

(ii) The name of the class is Rectangle

Option a is not correct because the <em>abstract</em> keyword is supposed to come before the <em>class</em> keyword.

Option c is not correct because the keyword <em>abstract</em> is missing. In other words, the class must be declared abstract since it contains abstract method findArea();

Option d is not correct because the <em>abstract</em> keyword is supposed to come before the <em>class</em> keyword.

7 0
3 years ago
Which type of classroom enables students to attend lectures without being physically present with the teacher?
Kisachek [45]
An online class? I think lol
5 0
4 years ago
You want to display the process of raising a scholarship request and its approval on a slide. Which element in the presentation
mario62 [17]

The answer is actually a flowchart, since flowcharts are used to show processes. The person who said it's a table is wrong, I just took this test on Plato and got a 5/5.

4 0
4 years ago
Spencer wants to choose a career path that wouldn’t hold him to an office or laboratory. Which of the following career paths wou
ruslelena [56]
Photography is the best choice but video game designers are also nice
please mark as brainliest
 
5 0
3 years ago
Read 2 more answers
From the perspective of the prosecution, the safest legal means of obtaining incriminating documents from a suspect is by: a. Su
never [62]

Answer:

a. Subpoena duces tectum

Explanation:

<u>Options C </u>(an informant steal the documents)<u> and D</u> (discrete copy of the documents) <u>would be considered illegal and/or inadmissible in most places</u>, so you should avoid these.

Options A (subpoena) and B (search warrant) are usually issued by a judge after considerations, so they are both legal ways to obtain something.

In a subpoena duces tecum, the court orders an individual (or a moral person) to produce (usually very specific) documents to court or face penalty.

<u>A search warrant is executed by law enforcement officials who are seeking information to help in their investigation</u>, usually not highly specific (not 'search for a copy of the April 10 minutes of the meeting.').

3 0
4 years ago
Other questions:
  • If a movie starts at 305 and the movie is 2 hrs and 44 mins when does the movie end?
    14·1 answer
  • A field that will always have a unique value is
    15·2 answers
  • You can advance slides during a slideshow by pressing the page down key
    7·1 answer
  • Describe two ways the ARPANET is different from the internet
    12·1 answer
  • Write a C++ program using a do while loop for (Find the highest score). The program should work for any number of students. Run
    10·1 answer
  • Which term is used to define the wires on a motherboard that move data from one part of a computer to another?
    13·1 answer
  • Which of the following optical storage media has the greatest storage capacity?
    10·1 answer
  • ก
    6·2 answers
  • Definition of the term social factor and explain why texting while driving can be classified as a social factor causing accident
    6·1 answer
  • Anybody know #3 ? I need two ppl to answer this !! Free Brainliest!!
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!