Results 1 to 4 of 4

Thread: trying from 8 hours eyes killing me Please need some helo

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    1

    trying from 8 hours eyes killing me Please need some helo

    .6 Currency (Weight: 4%)
    Problem Specification
    The problem concerns the conversion of currency from different countries and the commission the bank will charge for this. When converting currency, banks always charge a commission of a few percent or a fixed minimum commission – whichever is greater.
    Write a program to input data required to convert from another currency to Pounds. Also charge commission according to the method below.
    NOTE: 3 points are awarded for the program, an additional one for presenting a correct flow chart of the program to your tutor.

    Method
    1. Prompt and read 4 input parameters in this order:
     Commission rate (e.g. 1.4 for 1.4 percent)
     Currency to convert from (this is a 3-letter code, e.g. JPY for Japanese Yen, EUR for Euros, USD for US Dollars, etc)
     Rate of exchange to Pence (e.g.: 0.014 for Euros  2.80 Euros / 0.014 = 100 Pence)
     Amount of foreign currency to exchange (e.g. 327.55)
    2. Convert the foreign currency into Pence.
    3. If the Pence sum arising from this conversion is less than or equal to the minimum commission (5 Pounds in this exercise), print the message "Amount too small!"
    4. Now calculate the percentage commission. If this calculated percentage commission is less than the minimum commission, the payout will be the sterling amount (split into pounds and pence) minus the minimum commission.
    5. If the calculated percentage commission is greater than or equal to the minimum commission, the payout is the sterling amount (split into pounds and pence) minus the calculated commission.


    Hints
    The above Method can be written in Pseudo Code as shown below. This should help you to develop the flow chart:

    Code:
    START OF PROGRAM 
    	Set constant MIN_COMM to 500 (minimum commission is 500 pence) 
    	PROMPT and READ the 4 input parameters (in the correct order!) 
    	Calculate the amount in pence (penceAmount = foreignAmount / exRate;) 
    	IF penceAmount < MIN_COMM 
    		PRINT "Amount too small"
    	ELSE 
    		Calculate perc. commission (comm = penceAmount * commRate /100;) 
    		IF commision less than MIN_COMM 
    			commission=MIN_COMM 
    		END IF  
    		Split commission into Pounds and Pence 
    		PRINT commission Pounds and Pence  
    		actPayOut = penceAmount – commission
    		Split actPayOut into Pounds and Pence 
    		PRINT actPayOut Pounds and Pence 
    	END IF 
    END OF PROGRAM
    ---------------------------CODE-----------------------------------------

    Code:
    public class CheckCurrency{
    
    public static void main(String[] argv) {
          
      
          
          // put your local declarations here 
    
       
          String currencyToConvert;
          float amountToExchange, rateOfExchange, commission, amountExchanged;
    
          int exchangePounds, exchangePence, commissionPounds, commissionPence;
      
          
          // Prompt and read the commision rate 
      
          System.out.println ("Commission rate (percentage)");
          commission = UserInput.readFloat();
             
          // Prompt and read the three-letter currency code used by the industry
      
          System.out.println ("Currency to convert from");
          currencyToConvert = UserInput.readString();
        
          // Prompt and enter the conversion rate here
      
          System.out.println ("Rate of exchange to Sterling pence");
          rateOfExchange = UserInput.readFloat();
        
          // Prompt and read the amount of money to be converted here
      
          System.out.println ("Amount to exchange");
          amountToExchange = UserInput.readFloat();
         
          // Compute and print
      
          amountExchanged =  amountToExchange / rateOfExchange;
          commission = commission / amountToExchange * 100;        
          
          
          // Compute and print Exchange pounds and pence
      
          exchangePounds = (int)(amountExchanged / 100);
          exchangePence = (int) amountExchanged - exchangePounds * 100;
             
          System.out.println (amountToExchange + " " + currencyToConvert + " goes directly to " + exchangePounds + " pounds " + exchangePence + " pence");
           
          // Compute and print commission pounds and pence
       
          commissionPounds = (int) (commission / 100);
          commissionPence = (int) commission - commissionPounds * 100;
        ////////////////// //////////////////////////////////:wave: :wave: :wave: 
    if (exchangePounds <= commission){
        COM = 5;
        System.out.println ("Amount too small.");
        System.exit (0);
    }///////////////////////////////////////////////                                             :) :) 
          System.out.println ("Commission is " + commissionPounds + " pounds " + commissionPence + " pence");
          
           
          // Compute and print actual pound and pence
        
          System.out.println ("Actual sterling amount is " + exchangePounds + " pounds " + exchangePence + " pence");
        
          
          
       } // end of main
    
    } // end class
    --------------------------------CODE--------------------------------
    QUESTION IS COMMISSION IS NOT WORKING WITH IF STATMENT
    ANY HELP PLZZZZZZZZZZZZZZZZZ
    Last edited by mendhak; Jan 10th, 2009 at 05:14 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width