Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hyper operator

Name: Anonymous 2009-01-11 22:52

http://en.wikipedia.org/wiki/Hyper_operator
integralElem :: (Integral b) => [a] -> b -> a
hyper' :: (Integral a) => a -> (a -> a -> a)
hyper :: (Integral a) => a -> a -> a -> a

integralElem a b = a !! fromIntegral b

hyper' 0 = (+) . flip (^) 0
hyper' 1 = (+)
hyper' 2 = (*)
hyper' 3 = (^)
hyper' 4 = integralElem . (hyper4list)
    where hyper4list a = 1 : (zipWith (^) [a,a..] (hyper4list a))
hyper' n = integralElem . (hyperlist n)
    where hyperlist n a = 1 : (zipWith (hyper' (n-1)) [a,a..] (hyperlist n a))

hyper a n b = (hyper' n) a b


improvements to the above are welcome.

Name: Anonymous 2009-02-06 18:28

I need help converting from a double to an int or at least i need the values in amount paid to customer to be in the form xx.xx instead of xx.xxxxxxxxxxxxx(etc.)

/*
* CurrencyDollarConverter.java
* Author: MEMEMEMEMEMEMEMEME
* Last edited: 02/06/2009
*
* Purpose: CurrencyDollarConverter.java will display
* the details of a customer’s currency exchange transaction,
* as well as the amount of US Dollars and exact change paid
* to the customer after the currency exchange transaction has been made.
*
* Statement of Academic Honesty:
*
* The following code represents my own work. I have neither
* received nor given inappropriate assistance. I have not copied
* or modified code from any source other than the course webpage
* or the course textbook. I recognize that any unauthorized
* assistance or plagiarism will be handled in accordance with
* the University of Georgia's Academic Honesty Policy and the
* policies of this course.
*/

import java.awt.geom.Arc2D.Float;
import java.util.Scanner;

public class CurrencyDollarConverter {

    /* I would prefer calling the variable EXCHANGE_RATE as the 1.2% is a fixed rate
     * but the .pdf file says to label it as EXCHANGE_FEE. This would also prevent
     * confusion between the EXCHANGE_FEE and the later variable exchangeFee
     */

    public static final double EXCHANGE_FEE = 0.012;
    public static void main(String[] args) {
       
        /* variables */
       
        Double currencyExchangeRate;
        Double currencyAmount;
        Double dollarAmountUSA;
        Double dollarsForCustomer;
        Double exchangeFee;
        Integer twenties;
        Integer tens;
        Integer fives;
        Integer ones;
        Integer quarters;
        Integer dimes;
        Integer nickels;
        Integer pennies;
       
        /* inputs from the user */
       
        Scanner keyboard = new Scanner(System.in);
        System.out.println ("Please Enter First Name:\t");
        String firstName = keyboard.next();
        System.out.println ("Please Enter Last Name:\t");
        String lastName = keyboard.next();
        System.out.println ("Please Enter Currency Type:");
        String currencyType = keyboard.next();
        System.out.println ("Please Enter Currency Exchange Rate:");
        currencyExchangeRate = keyboard.nextDouble();
        System.out.println ("Please Enter Amount Of Currency:");
        currencyAmount = keyboard.nextDouble();
       
        /* math and computation */
               
        dollarAmountUSA = currencyAmount*currencyExchangeRate;
        exchangeFee = dollarAmountUSA*EXCHANGE_FEE;
        dollarsForCustomer = dollarAmountUSA - exchangeFee;
       
        /* computation for "change paid to customer" */
       
        int(dollarsForCustomer) = intDollarsForCustomer;
        twenties = dollarsForCustomer / 20;
        dollarsForCustomer = dollarsForCustomer % 20;
        tens = dollarsForCustomer / 10;
       
        quarters = dollarsForCustomer / 25;
        dollarsForCustomer = dollarsForCustomer % 25;
        dimes = dollarsForCustomer / 10;
        dollarsForCustomer = dollarsForCustomer % 10;
        nickels = dollarsForCustomer / 5;
        dollarsForCustomer = dollarsForCustomer % 5;
        pennies = dollarsForCustomer;
       
        /* outputs from the program */
       
        System.out.println ("Currency Transaction Summary: ");
        System.out.println ("Customer: " +lastName + ", " + firstName);
        System.out.println ("Currency Amount: " + currencyAmount + "(" + currencyType + ")");
        System.out.println ("Currency Exchange Rate: " + currencyExchangeRate + " US Dollar per " + currencyType);
        System.out.println ("US Dollar Amount: " + dollarAmountUSA);
        System.out.println ("Exchange Fee (1.2%: " + exchangeFee);
        System.out.println ("Total US Dollars: " + dollarsForCustomer);
        System.out.println ();
            System.out.println ("Amount paid to customer: " +dollarsForCustomer);
            System.out.println ("Exact change paid to customer:");
                System.out.println (twenties + "Twenty Dollar Bills");
                System.out.println (tens + "Ten Dollar Bills");
                System.out.println (fives + "Five Dollar Bills");
                System.out.println (ones + "One Dollar Bills");
                System.out.println (quarters + "Quarters");
                System.out.println (dimes + "Dimes");
                System.out.println (nickels + "Nickels");
                System.out.println (pennies + "Pennies");
    }       
   

}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List