Prompt the user to input the maximum exchange USD amount (as double)

computer science

Description

Purpose of this assignment:

  • Using with different data types
  • Using arithmetic operators
  • Using casting operators
  • Using conditional statements (if-else)
  • Using system.exit(0) for exiting the program

Assignment:

Write a Java program named ExchangeCAD to exchange US Dollar (USD$) to Canadian Dollar (CAD$) with the following tasks:

  • Prompt the user to input the maximum exchange USD amount (as double)
    • If the input value is negative, output an error message and exit the program.
  • Prompt the user to input the USD amount for exchange (as double)
    • If the input value is negative, output an error message and exit the program.
  • Using USD$ 1 = CAD$1.3170 as the exchange rate
  • Calculate and output the number of each paper currency CAD$ being exchanged to.  Here is the list of all paper currency in CAD$
    • CAD$1000
    • CAD$100
    • CAD$50
    • CAD$20
    • CAD$10
    • CAD$5
    • CAD$2
    • CAD$1
  • Calculate and output the number of each coin currency CAD$ being exchanged to.  Here is the list of all coin currency in CAD$:
    • CAD$0.25
    • CAD$0.10
    • CAD$0.05
    • CAD$0.01
  • Output the total amount of CAD$ being exchanged
  • Output the remaining USD$ not being exchanged due to maximum exchange amount


Related Questions in computer science category