Question

Write a program called "ConvertPennies" to input an integer value representing a number of pennies and...

Write a program called "ConvertPennies" to input an integer value representing a number of pennies and convert it to its equivalent number of Dollars, Quarters, Dimes, Nickels and Pennies.

Following is the result of the execution of this program for 292 pennies.

Enter the amount of pennies to convert:
292 pennies is equal to

2 one dollar bills
3 quarters
1 dimes
1 nickels
2 pennies

Have a nice day!

This is given:

//**********************************************************************
// Programmer: Your first and last names
// Problem Description:
// Convert a number of pennies into its equivalent larger denominations.
//**********************************************************************

import java.util.Scanner;
public class yourprogramname {

   public static void main(String[] args) {
       // Declare the identifiers

       // Create a Scanner object.
      
       // Input the number of pennies to convert

       // Convert the amount into its equivalent denominations
  
       // Display the result

   }
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

// ConvertPennies.java

import java.text.NumberFormat;
import java.util.Scanner;

public class ConvertPennies {

   public static void main(String[] args) {
       // Declare the identifiers
      
       int dollars;
       int pennies,nickles,dimes,quarters;

       // Create a Scanner object.
       /*
       * Creating an Scanner class object which is used to get the inputs
       * entered by the user
       */
       Scanner sc = new Scanner(System.in);

       // Input the number of pennies to convert
       System.out.print("Enter Pennies :");
       pennies=sc.nextInt();
       // Convert the amount into its equivalent denominations
dollars=pennies/100;
pennies=pennies%100;
  
quarters=pennies/25;
pennies=pennies%25;
  
dimes=pennies/10;
pennies=pennies%10;
  
nickles=pennies/5;
pennies=pennies%5;
  

      
       // Display the result
System.out.println(dollars+" one dollar bills");
System.out.println(quarters+" quarters");
System.out.println(dimes+" dimes");
System.out.println(nickles+" nickels");
System.out.println(pennies+" pennies");

      
   }
}

============================

Output:

Enter Pennies :292
2 one dollar bills
3 quarters
1 dimes
1 nickels
2 pennies

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Write a program called "ConvertPennies" to input an integer value representing a number of pennies and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write a PHP program makes change for a given number of cents. The program should ask...

    write a PHP program makes change for a given number of cents. The program should ask the user for the amount of cents and then output the change for specific denominations of ten dollar bills, five dollar bills, one dollar bills, quarters, dimes, nickels, and pennies. Here is a sample program output for an input of 265 cents: Change for 2 dollars and 65 cents : 0 ten dollar bills 0 five dollar bills 2 one dollar bills 2 quarters...

  • (In Python 3) Write a program with total change amount as an integer input, and output...

    (In Python 3) Write a program with total change amount as an integer input, and output 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: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes So...

  • I have this code but when there's 0 pennies, it doesn't output "and 0 pennies" at...

    I have this code but when there's 0 pennies, it doesn't output "and 0 pennies" at all, it is just left blank. package edu.wit.cs.comp1050; /** * Solution to the third programming assignment * When it runs it outputs the amount in quarters, dimes, nickels and pennies * * @author Rose Levine * */ import java.util.Scanner; public class PA1c {       /**    * Error message to display for negative amount    */    public static final String ERR_MSG =...

  • Write a program with total change amount as an integer input, and output the change using...

    Write a program with total change amount as an integer input, and output 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: 0 the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes

  • Write a C program that calculates exact change. In order to receive full credit, please remember...

    Write a C program that calculates exact change. In order to receive full credit, please remember that only int arithmetic is exact, so you’ll need to break up your double into two ints, the one before the decimal point and the one after the decimal point. Another point worth mentioning is that the % operator gives the remainder. In other words, when working with int values, 9 / 5 = 1 whereas 9 % 5 = 4. Keep this in...

  • Write a program called CountCoins.java that prompts the user for the input file name (you can...

    Write a program called CountCoins.java that prompts the user for the input file name (you can copy the getInputScanner() method given in the ProcessFile assignment) then reads the file. The file contains a series of pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be “pennies” (1 cent each), “nickels” (5 cents each), “dimes” (10 cents each), or “quarters” (25 cents each), case-insensitively. Add up the cash values of...

  • it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dolla...

    it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dollar amount as an integer: $5.34 is input as 534 b. Use a constant variable to represent each coin as a fixed value: const int NICKEL 5; c. Use division and the mod function to calculate the number of each coin. Change Calculator Enter dollar amount (as an integer): $534 The equivalent in coins: 21 Quarters 0 Dimes 1 Nickels...

  • 2. Write a JAVA program that prints the numbe r of quarters, dimes, nickels, and pennies...

    2. Write a JAVA program that prints the numbe r of quarters, dimes, nickels, and pennies that a customer should get back as change. Declare and initialize all memory locations as integers. On Output show the original change amount as a monetary amount with the two positions of decimal. Run your program once by performing a compile-time initializations using 92 cents for the calue to be converted. Go into your source code and change the 92 to 27. Return the...

  • In c++ Write a program that asks users to input the amount of money (in cents)...

    In c++ Write a program that asks users to input the amount of money (in cents) that will be exchanged to the least number of coins of the same value, output the results. Assume there are quarters (25c), dimes (10c), nickels(5c) and pennies(1c) available. ■CA 32 cmd.e eas input the anount of money (in cents) you want to exchange 39 39 can be exchanged to uarter: 25 me: 1 kel: e enny: 4 ress any key to continue-.

  • Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10...

    Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 pennies. 2. Repeatedly prompt the user for a price in the form xX.xx, where X denotes a digit, or to enter q' to quit 3. When a price is entered a. If the price entered is negative, print an error message and start over requesting either a new price or to quit (indicated by entering a 'q)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT