Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Jump to level 1 Convert totalDollars to 2 0 - dollar bills, 5 - dollar bills, and one - dollar bills, finding the maximum number

Jump to level 1
Convert totalDollars to 20-dollar bills, 5-dollar bills, and one-dollar bills, finding the maximum number of 20-dollar bills, then 5 dollar bills, then one-dollar bills.
Ex: If the input is 29, then the output is:
20-dollar bills: 1
5-dollar bills: 1
One-dollar bills:
Note: A 20-dollar bill is 20 one-dollar bills. A 5-dollar bill is 5 one-dollar bills.
import java.util.Scanner;
public class MoneyConverter {
public static void main(String[] args){
Scanner scnr = new Scanner(
System.in);
int totalDollars;
int numTwenties;
int numFives;
int numones;
totalDollars = scnr. nextInt () ;
Y* Your code goes here */ I
System.out.println("20-dollar bills: "+ numTwenties);
System.out.println("5-dollar bills: "+ numFives);
System.out.println("One-dollar bills: "+ numones);
1
2
3
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions