answer.
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
ikadub
26 days 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:
zubka84 [945]26 days ago
3 0

Answer:

The following program is written in python programming language:

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

#Check if the input is less than 1

if amount<=0:

print("No Change")

else: #If input is valid

#Convert input into different coins

dollar = int(amount/100) #Dollar conversion

amount = amount % 100 #Calculate remainder

quarter = int(amount/25) #Quarter conversion

amount = amount % 25 #Calculate remainder

dime = int(amount/10) #Dime conversion

amount = amount % 10 #Calculate remainder

nickel = int(amount/5) #Nickel conversion

penny = amount % 5 #Calculate remainder

#Display 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 implemented using python and includes comments for clarification.

The variable amount is defined as an integer.

The check in line 3 determines if the amount is less than or equal to 0.

If it is, "No Change" is printed.

If not, it converts the entered amount into smaller coins.

Line 7 converts the input amount to its dollar counterpart.

Line 8 calculates the remainder.

Line 9 converts the remainder to quarters.

Line 10 calculates the new remainder.

Line 11 converts the current remainder to dimes.

Line 12 calculates the adjusted remainder.

Line 13 calculates the nickel equivalent.

Line 14 gets the penny equivalent of what's left.

Lines 16 and beyond display the result using the correct terminology (singular or plural).

You might be interested in
Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number w
zubka84 [945]

Answer:

The code placed where "/*Your solution goes here */" is as follows:

while(numInsects<200) // while loop

       {

            System.out.print(numInsects+" "); // output statement

            numInsects=numInsects*2; // operation to double the value.

       }

Output:

  • If the input is 16, the result is 16 32 64 128.
  • If the input is 25, the result is 25 50 100.

Explanation:

  • The above Java code fills the section designated as "Your solution" and will operate correctly.
  • The program accepts a user input and continues to print double the value until it reaches 200 or more.
  • The while loop evaluates whether the value remains below 200. If so, the operation proceeds; otherwise, it stops.
5 0
1 month ago
Sushant is a new manager and he wants to share his ideas and working protocol with his team.Compare the advantages and disadvant
oksian1 [804]

Answer:

Benefits of Oral Communication

  1. Utilizing visual aids such as PowerPoint during discussions can enhance his team's understanding of his concepts and procedures.
  2. Staff responses tend to be more immediate and sincere compared to written replies.

Drawbacks of Oral Communication

  1. If Sushant struggles with stage fright or lacks strong communication skills, it may negatively impact the team's perception of him.
  2. There is a risk that staff may forget portions of Sushant's spoken communication, as written information is generally more reliable for retention.

Benefits of Written Communication

  1. A well-crafted memo articulates Sushant's ideas and procedures clearly to the staff.
  2. A feedback questionnaire could be included for staff input.
  3. Clearly stated goals and objectives.

Drawbacks of Written Communication

  1. Excessively lengthy written material may pose challenges for comprehension or retention.

It is advisable for Sushant to prioritize written communication to share his ideas and protocols effectively.

3 0
1 month ago
Dante has a worksheet shared with multiple users. He would like the ability to approve or reject changes that are made. Which fe
oksian1 [804]
Data Consolidation.
7 0
18 days ago
Input a number [1-50] representing the size of the shape and then a character [x,b,f] which represents the shape i.e. x-&gt;cros
Harlamova29_29 [932]

Response:

C++ code provided below with suitable annotations

Clarification:

pattern.cpp

#include<iostream>

using namespace std;

void printCross(int n)

{

int i,j,k;

if(n%2) //odd number of lines

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==i || j==(n-i+1))

cout<<j;

else

cout<<" ";

}

cout<<"\n";

}

}

else //even number of lines

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==i || j==(n-i+1))

{

cout<<" "<<j<<" ";

}

else

cout<<" ";

}

cout<<"\n";

}

}

void printForwardSlash(int n)

{

if(n%2)

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==n-i+1)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

else

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==(n-i+1))

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

}

void printBackwardSlash(int n)

{

if(n%2) // odd number of lines

{

for(int i=n;i>=1;i--)

{

for(int j=n;j>=1;j--)

{

if(j==i)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

else //even number of lines

{

for(int i=1;i<=n;i++)

{

for(int j=1;j<=n;j++)

{

if(j==i)

{

cout<<j;

}

else

cout<<" ";

}

cout<<"\n";

}

}

}

int main()

{

int num;

char ch;

cout<<"Create a numberes shape that can be sized."<<endl;

cout<<"Input an integer [1,50] and a character [x,b,f]."<<endl;

cin>>num>>ch;

if(ch=='x' || ch=='X')

printCross(num);

else if(ch=='f' || ch=='F')

printForwardSlash(num);

else if(ch=='b' || ch=='B')

printBackwardSlash(num);

else

cout<<"\nWrong input"<<endl;

return 0;

}

4 0
20 days ago
Given a pattern as the first argument and a string of blobs split by | show the number of times the pattern is present in each b
Amiraneli [921]

Response:

The code is provided below

Clarification:

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.nio.charset.StandardCharsets;

public class Main {

  /**

  *

  * Process each line of input.

  *

  */

  public static void main(String[] args) throws IOException {

      InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);

      BufferedReader in = new BufferedReader(reader);

      String line;

      while ((line = in.readLine())!= null) {

          String[] splittedInput = line.split(";");

          String pattern = splittedInput[0];

          String blobs = splittedInput[1];

          Main.doSomething(pattern, blobs);

      }

  }

  public static void doSomething(String pattern, String blobs) {

      // Implement your code here. You can create more methods or classes if needed

      int total = 0;

      String arrblobs[] = blobs.split("\\|");

      for (int i = 0; i < arrblobs.length; ++i) {

          int count = 0, index = 0;

          for (;;) {

              int position = arrblobs[i].indexOf(pattern, index);

              if (position < 0)

                  break;

              count++;

              index = position + 1;

          }

          System.out.print(count + "|");

         

          total += count;

      }

      System.out.println(total);

  }

}

5 0
1 month ago
Other questions:
  • 9) If you are working on the part of 5-15 minutes, time-stamping (every 30 seconds) should start at: a) [00:05:00] b) [00:00:00]
    9·1 answer
  • Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename
    6·2 answers
  • array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting o
    11·1 answer
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • When performing actions between your computer and one that is infected with a virus which of the following offers no risk becomi
    5·1 answer
  • A company decides to relocate its operations to another state in order to take advantage of some new business investment credits
    15·1 answer
  • On the planet Sigma, robots excavate chunks of a very precious cristaline. These chunks can be divided into smaller part only on
    15·1 answer
  • Assign max_sum with the greater of num_a and num_b, PLUS the greater of num_y and num_z. Use just one statement. Hint: Call find
    5·1 answer
  • James is an intern in a film production company. On his first day, James’ boss, Monica, tells him, “Before anything else, let me
    9·1 answer
  • A router has a valid operating system and a configuration file stored in nvram. the configuration file contains an enable secret
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!