Description
Background
A Fortune 500 company that runs currency exchange kiosks in all the major airports around the world has recently viewed your programming work. They were very impressed and now have a special job for you. The currency conversion software they currently have is long obsolete and no longer runs efficiently in their exchange machines. This is partly because the last group of people to write the code did not build the program’s functionality into separate methods but rather jammed all their code into the main() method, which later proved to be a total disaster. Your assignment is to write an allnew version of the program that uses methods so that they can get their exchange booths back up and running and avoid losing customers. The kiosks allow the user to deposit money into their account (this is a temporary account that only exists until the user is finished with all his/her conversions), view the remaining U.S. dollar balance in the user’s account, and withdraw arbitrary amounts in any currency that the machine supports.
Your Assignment
Your task is to write a Java program for the kiosk machines that can perform the tasks described above at the user’s request. The task begins by printing a quick welcome message, displaying a table of currency values, and then proceeding to the main menu. At that point, the customer can A) Have their remaining balance displayed,
B) Deposit a certain amount of one currency into their account and convert it into U.S. dollars, C) Withdraw a certain amount from their remaining balance in a particular currency, or D) End their transaction which will give them back all of their remaining balance in U.S. dollars. Upon completion of A, B, or C, the program will return to the main menu (loop). IMPTNT: Since this company is a U.S.based firm, options B) will automatically convert any deposit currency into US dollars i.e. The account only holds a U.S dollar balance. When the user withdraws a certain amount of their remaining balance in a particular currency except SD, the amount will be converted from U.S. dollar balance plus 0.5% of total withdrawal amount as convenience fee. xample: The user has a $10 U.S. dollar balance in their account. If they want to withdraw 0.89 Euros from the account, the total amount withdrawn from the account is calculated as: amount = 0.89 / 0.89 * (1+0.005) = $1.005 USD. His/her remaining balance will be $8.995 USD ALL currency values will be stored as type double. There should be a balance variable in the class to store the balance of the account. Deposit/Withdraw amount should always be positive numbers. For simplicity, when withdrawing and depositing from/to the account, the value of the remaining balance should be rounded up to 2 significant digits both when displayed and saved. Round up is NOT required in conversions. The way to round up to a specific significant digit can be found in previous Labs. Please use the code below to update the balance so that it has 2 digits after the decimal. This should only be used in Options B) and C) private static boolean updateBalance(double newBalance) { balance = Math.round(newBalance * 100) / 100.0; if (balance = 0) { return true; } else return false; }
The currency conversion table (methods of conversion will be discussed later) that you are required to use is displayed below. D NT use any other conversion table found online as the values of these currencies are likely to change. S Dollar 1.00 Euro 0.89 British Pound 0.78 Indian Rupee 66.53 Australian Dollar 1.31 Canadian Dollar 1.31 Singapore Dollar 1.37 Swiss Franc 0.97 Malaysian Ringgit 4.12 Japanese Yen 101.64 Chinese Yuan Renminbi 6.67
Mandatory Methods
For your convenience, we created a skeleton source file for you(including all the mandatory methods), please use the skeleton file to start your project. P the balance variable, getBalance()and updateBalance() methods unchanged. The following are a list of MNDT methods that you must use/implement in your program. The functionality found in these methods may not be created anywhere else in the program We will only grade your methods. Not creating the methods exactly as described below will cause you to lose points as well as make your code disorganized and hard to understand. The methods will be tested using test cases. Some test cases are corner cases such as negative amount, divide by zero etc. When implementing these methods, considering the potential corner cases carefully. You may create additional methods, however, you MUST have the methods listed below. 7 Mandatory methods: / * * * P r i n t s t h e c o n v e r s i o n t a b l e a t t h e s t a r t o f t h e p r o g r a m ( s e e t h e o u t p u t e x a m p l e s ) . * / p u b l i c s t a t i c v o i d p r i n t C o n v e r s i o n T a b l e ( )
/ * * * P r i n t s t h e m a i n m e n u ( s e e o u t p u t e x a m p l e s ) , a l l o w s t h e u s e r t o m a k e a s e l e c t i o n f r o m a v a i l a b l e o p e r a t i o n s * * @ p a r a m i n p u t t h e S c a n n e r o b j e c t y o u c r e a t e d a t t h e b e g i n n i n g o f t h e m a i n m e t h o d . A n y v a l u e o t h e r t h a n t h e 4 v a l i d s e l e c t i o n s s h o u l d g e n e r a t e a n i n v a l i d v a l u e p r o m p t . P r i n t t h e l i s t a g a i n a n d p r o m p t u s e r t o s e l e c t a v a l i d v a l u e f r o m t h e l i s t . * @ r e t u r n a n i n t e g e r f r o m 1 ‐ 4 i n c l u s i v e r e p r e s e n t i n g t h e u s e r ’ s s e l e c t i o n . * / p u b l i c s t a t i c i n t m a i n M e n u O p t i o n S e l e c t o r ( S c a n n e r i n p u t )
/ * * * P r i n t s t h e c u r r e n c y m e n u ( s e e o u t p u t e x a m p l e s ) , a l l o w s t h e u s e r t o m a k e a s e l e c t i o n f r o m a v a i l a b l e c u r r e n c i e s * * @ p a r a m i n p u t t h e S c a n n e r o b j e c t y o u c r e a t e d a t t h e b e g i n n i n g o f t h e m a i n m e t h o d . A n y v a l u e o t h e r t h a n t h e 1 1 v a l i d v a l i d c u r r e n c y t y p e s s h o u l d g e n e r a t e a n i n v a l i d v a l u e p r o m p t . P r i n t t h e l i s t a g a i n a n d p r o m p t u s e r t o s e l e c t a v a l i d v a l u e f r o m t h e l i s t . t h e c u r r e n c y t y p e w i l l b e t h e s a m e a s t h e t y p e n u m b e r u s e d i n { @ l i n k # c o n v e r t C u r r e n c y ( d o u b l e , i n t , b o o l e a n ) } * @ r e t u r n a n i n t e g e r f r o m 1 ‐ 1 1 i n c l u s i v e r e p r e s e n t i n g t h e u s e r ’ s s e l e c t i o n . * / p u b l i c s t a t i c i n t c u r r e n c y M e n u O p t i o n S e l e c t o r ( S c a n n e r i n p u t ) / * * * C o n v e r t t h e v a l u e a m o u n t b e t w e e n U . S . d o l l a r s a n d a s p e c i f i c c u r r e n c y . * * @ p a r a m a m o u n t T h e a m o u n t o f t h e c u r r e n c y t o b e c o n v e r t e d . * @ p a r a m c u r r e n c y T y p e T h e i n t e g e r c u r r e n c y T y p e w o r k s a s f o l l o w s : * 1 f o r u s d ( U . S . D o l l a r s ) * 2 f o r e u r ( E u r o s ) * 3 f o r b r i ( B r i t i s h P o u n d s ) * 4 f o r i n r ( I n d i a n R u p e e s )
* 5 f o r a u s ( A u s t r a l i a n D o l l a r s ) * 6 f o r c n d ( C a n a d i a n D o l l a r s ) * 7 f o r s i d ( S i n g a p o r e D o l l a r s ) * 8 f o r s w f ( S w i s s F r a n c s ) * 9 f o r m a r ( M a l a y s i a n R i n g g i t s ) * 1 0 f o r j p y ( J a p a n e s e Y e n ) * 1 1 f o r c y r ( C h i n e s e Y u a n R e n m i n b i ) * @ p a r a m i s C o n v e r t T o U S D T e l l s t h e d i r e c t i o n o f t h e c o n v e r s i o n . I f t h e v a l u e i s t r u e , t h e n t h e c o n v e r s i o n i s f r o m a f o r e i g n c u r r e n c y t o U S D . I f t h e v a l u e i s f a l s e , t h e n t h e c o n v e r s i o n i s f r o m U S D t o t h e f o r e i g n c u r r e n c y * @ r e t u r n t h e c o n v e r t e d a m o u n t * / p u b l i c s t a t i c d o u b l e c o n v e r t C u r r e n c y ( d o u b l e a m o u n t , i n t c u r r e n c y T y p e , b o o l e a n i s C o n v e r t T o U S D )
/ * * * d e p o s i t t h e a m o u n t o f a s p e c i f i c c u r r e n c y t o t h e a c c o u n t * * @ p a r a m a m o u n t t h e a m o u n t t o b e d e p o s i t e d . * @ p a r a m c u r r e n c y T y p e t h e c u r r e n c y t y p e w i l l b e t h e s a m e a s t h e t y p e n u m b e r u s e d * i n t h e c o n v e r t C u r r e n c y ( d o u b l e , i n t , b o o l e a n ) m e t h o d . A n I n v a l i d * t y p e w i l l r e s u l t i n a d e p o s i t f a i l u r e . * @ r e t u r n i f d e p o s i t s u c c e e d s ( p o s i t i v e a m o u n t n o t z e r o ) , * t h e m e t h o d w i l l r e t u r n * t r u e . o t h e r w i s e , r e t u r n f a l s e * / p u b l i c s t a t i c b o o l e a n d e p o s i t ( d o u b l e a m o u n t , i n t c u r r e n c y T y p e )
/ * * * w i t h d r a w t h e v a l u e a m o u n t w i t h a s p e c i f i c c u r r e n c y f r o m t h e a c c o u n t . T h e w i t h d r a w a m o u n t s h o u l d n e v e r e x c e e d t h e c u r r e n t a c c o u n t b a l a n c e , o r t h e w i t h d r a w a l w i l l f a i l . I f t h e c u r r e n c y i s o t h e r t h a n U S D , a 0 . 5 % c o n v e n i e n c e f e e w i l l b e c h a r g e d * * @ p a r a m a m o u n t t h e a m o u n t t o b e w i t h d r a w n . * @ p a r a m c u r r e n c y T y p e t h e c u r r e n c y t y p e w i l l b e t h e s a m e a s t h e t y p e n u m b e r u s e d * i n t h e c o n v e r t C u r r e n c y ( d o u b l e , i n t , b o o l e a n ) m e t h o d . A n i n v a l i d * t y p e w i l l r e s u l t a w i t h d r a w f a i l u r e . * @ r e t u r n i f w i t h d r a w s u c c e e d , w i l l r e t u r n t r u e . I f f a i l e d , r e t u r n f a l s e * / p u b l i c s t a t i c b o o l e a n w i t h d r a w ( d o u b l e a m o u n t , i n t c u r r e n c y T y p e ) / * * * D i s p l a y s m e s s a g e a t t h e e n d o f t h e w i t h d r a w , d e p o s i t , a n d e n d T r a n s a c t i o n s t a t i n g * h o w m u c h t h e u s e r j u s t w i t h d r e w / d e p o s i t e d a n d w h a t t y p e ( t h i s w i l l b e u s e d i n b o t h f e a t u r e s B , C a n d D o f t h e m a i n m e n u ) . * * @ p a r a m a m o u n t t h e a m o u n t o f c u r r e n c y w i t h d r e w / d e p o s i t e d * @ p a r a m c u r r e n c y T y p e t h e c u r r e n c y t y p e w i l l b e t h e s a m e a s t h e t y p e n u m b e r u s e d * i n { @ l i n k # c o n v e r t C u r r e n c y ( d o u b l e , i n t , b o o l e a n ) } * @ p a r a m i s D e p o s i t i f t r u e l o g t h e d e p o s i t t r a n s a c t i o n , f a l s e l o g t h e w i t h d r a w t r a n s a c t i o n * @ r e t u r n R e t u r n t h e f o r m a t t e d l o g m e s s a g e a s f o l l o w i n g e x a m p l e s : * You successfully withdrew 10.0 U.S. Dollars
* You successfully deposited 30.0 Japanese Yen * * I n v a l i d i n p u t l i k e i n v a l i d c u r r e n c y T y p e o r n e g a t i v e a m o u n t , * w i l l r e t u r n a “ L o g g i n g E r r o r ” * / p u b l i c s t a t i c S t r i n g l o g T r a n s a c t i o n ( d o u b l e a m o u n t , i n t c u r r e n c y T y p e , b o o l e a n i s D e p o s i t )
Submission Requirements
Read the description for each mandatory method carefully ● Name the class “CurrencyExchange”. All Mandatory methods should reside in the CurrencyExchange Class. The source file should be named as “CurrencyExchange.java”. Please use the EXACT class name and source file name, or you will have a grade. ● ip the java file ITHT any folder hierarchy in a zip file. (or you will get a zero grade) ● Name the zip file project3_uflid.zip where uflID is the alphanumeric portion of your UF email account that comes before the ufl.edu part. ● Submit using Canvas If you submit the .java file without zipping, your project will not be graded. If your file is not named project3_uflid.zip, your project will not be graded. If you do not name the Project and class exactly as specified, your project will not be graded. Please only create one Scanner object to read input, otherwise, the autograder will not be able to provide input. It is highly recommended that you test your program piece by piece before assembling your final code. You will have a much easier time if you build your program piece by piece rather than trying to write the entire program. Pay very close attention to the order that you give inputs to the sample program. Your output should not differ in any way from the sample output. Using additional prompts, words, abbreviations, etc may result in the grading program taking unnecessary points off. rading ● 100% of your program will be graded on its ability to generate proper output and using all of the mandatory methods. Sample Run 1 (user input is in red) Welcome to Currency Exchange 2.0 Current rates are as follows: 1 U.S. Dollar 1.00 2 Euro 0.89 3 British Pound 0.78 4 Indian Rupee 66.53 5 Australian Dollar 1.31 6 Canadian Dollar 1.31 7 Singapore Dollar 1.37 8 Swiss Franc 0.97
9 Malaysian Ringgit 4.12 10 Japanese Yen 101.64 11 Chinese Yuan Renminbi 6.67 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 2 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 8 Please enter the deposit amount: 2.91 You successfully deposited 2.91 Swiss Francs Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 1 Your current balance is: 3.0 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 3 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars
8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 1 Please enter the withdrawal amount: 1 You successfully withdrew 1.0 U.S. dollars Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 1 Your current balance is: 2.0 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 3 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 8 Please enter the withdrawal amount: 0.97 You successfully withdrew 0.97 Swiss Francs Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 1 Your current balance is: 1.0 Please select an option from the list below: 1. Check the balance of your account
2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 4 You successfully withdrew 1.0 U.S. Dollars Goodbye Sample Run 2 (user input is in red) Welcome to Currency Exchange 2.0 Current rates are as follows: 1 U.S. Dollar 1.00 2 Euro 0.89 3 British Pound 0.78 4 Indian Rupee 66.53 5 Australian Dollar 1.31 6 Canadian Dollar 1.31 7 Singapore Dollar 1.37 8 Swiss Franc 0.97 9 Malaysian Ringgit 4.12 10 Japanese Yen 101.64 11 Chinese Yuan Renminbi 6.67 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 2 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 10 Please enter the deposit amount: 203.28 You successfully deposited 203.28 Japanese Yen Please select an option from the list below: 1. Check the balance of your account
2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 1 Your current balance is: 2.0 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 3 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 1 Please enter the withdrawal amount: 1 You successfully withdrew 1.0 U.S. dollars Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 1 Your current balance is: 1.0 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 0 Input failed validation. Please try again. Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars)
5 Input failed validation. Please try again. Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 4 You successfully withdrew 1.0 U.S. dollars Goodbye Sample Run 3 (user input is in red) Welcome to Currency Exchange 2.0 Current rates are as follows: 1 U.S. Dollar 1.00 2 Euro 0.89 3 British Pound 0.78 4 Indian Rupee 66.53 5 Australian Dollar 1.31 6 Canadian Dollar 1.31 7 Singapore Dollar 1.37 8 Swiss Franc 0.97 9 Malaysian Ringgit 4.12 10 Japanese Yen 101.64 11 Chinese Yuan Renminbi 6.67 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 2 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 0 Input failed validation. Please try again.
Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 12 Input failed validation. Please try again. Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 11 Please enter the deposit amount: 6.67 You successfully deposited 6.67 Chinese Yuan Renminbi Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 1 Your current balance is: 1.0 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 3 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees
5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 1 Please enter the withdrawal amount: 1.01 Error: Insufficient funds. Logging Error Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 3 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 1 Please enter the withdrawal amount: 1 You successfully withdrew 1.0 U.S. dollars Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 4 Your remaining balance is 0.0 U.S. Dollars Goodbye Sample Run 4 (user input is in red) Welcome to Currency Exchange 2.0 Current rates are as follows:
1 U.S. Dollar 1.00 2 Euro 0.89 3 British Pound 0.78 4 Indian Rupee 66.53 5 Australian Dollar 1.31 6 Canadian Dollar 1.31 7 Singapore Dollar 1.37 8 Swiss Franc 0.97 9 Malaysian Ringgit 4.12 10 Japanese Yen 101.64 11 Chinese Yuan Renminbi 6.67 Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 2 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 1 Please enter the deposit amount: 100 Logging Error Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 2 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits
10. Japanese Yen 11. Chinese Yuan Renminbi 1 Please enter the deposit amount: 0 Logging Error Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 3 Please select the currency type: 1. U.S. Dollars 2. Euros 3. British Pounds 4. Indian Rupees 5. Australian Dollars 6. Canadian Dollars 7. Singapore Dollars 8. Swiss Francs 9. Malaysian Ringgits 10. Japanese Yen 11. Chinese Yuan Renminbi 1 Please enter the withdrawal amount: 100 Logging Error Please select an option from the list below: 1. Check the balance of your account 2. Make a deposit 3. Withdraw an amount in a specific currency 4. End your session (and withdraw all remaining currency in U.S. Dollars) 4 Your remaining balance is 0.0 U.S. Dollars Goodbye