The following warnings occurred:
Warning [2] Undefined array key "extra" - Line: 100 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 100 errorHandler->error
/inc/plugins/google_seo.php 311 require_once
/inc/class_plugins.php 38 require_once
/inc/init.php 233 pluginSystem->load
/global.php 18 require_once
/printthread.php 16 require_once
Warning [2] Undefined variable $location - Line: 1250 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 1250 errorHandler->error
/inc/plugins/google_seo/url.php 174 google_seo_url_hook
/inc/plugins/google_seo.php 311 require_once
/inc/class_plugins.php 38 require_once
/inc/init.php 233 pluginSystem->load
/global.php 18 require_once
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.0.30 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.0.30 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.0.30 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5025 - File: inc/functions.php PHP 8.0.30 (Linux)
File Line Function
/inc/functions.php 5025 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7271 - File: inc/functions.php PHP 8.0.30 (Linux)
File Line Function
/inc/functions.php 7271 errorHandler->error
/inc/functions.php 5045 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7271 - File: inc/functions.php PHP 8.0.30 (Linux)
File Line Function
/inc/functions.php 7271 errorHandler->error
/inc/functions.php 5045 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7271 - File: inc/functions.php PHP 8.0.30 (Linux)
File Line Function
/inc/functions.php 7271 errorHandler->error
/inc/functions.php 5045 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$bottomlinks_returncontent - Line: 6 - File: global.php(938) : eval()'d code PHP 8.0.30 (Linux)
File Line Function
/global.php(938) : eval()'d code 6 errorHandler->error
/global.php 938 eval
/printthread.php 16 require_once
Warning [2] Trying to access array offset on value of type null - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1381 google_seo_url_cache
/inc/functions.php 5890 google_seo_url_forum
/printthread.php 213 get_forum_link
/printthread.php 67 makeprintablenav
Warning [2] Trying to access array offset on value of type null - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1381 google_seo_url_cache
/inc/functions.php 5890 google_seo_url_forum
/printthread.php 213 get_forum_link
/printthread.php 67 makeprintablenav
Warning [2] Undefined array key 82 - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1381 google_seo_url_cache
/inc/functions.php 5890 google_seo_url_forum
/printthread.php 213 get_forum_link
/printthread.php 218 makeprintablenav
/printthread.php 67 makeprintablenav
Warning [2] Undefined array key 85 - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1381 google_seo_url_cache
/inc/functions.php 5890 google_seo_url_forum
/printthread.php 213 get_forum_link
/printthread.php 218 makeprintablenav
/printthread.php 218 makeprintablenav
/printthread.php 67 makeprintablenav
Warning [2] Undefined array key 4 - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1412 google_seo_url_cache
/inc/functions.php 5922 google_seo_url_thread
/printthread.php 124 get_thread_link
Warning [2] Trying to access array offset on value of type null - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1412 google_seo_url_cache
/inc/functions.php 5922 google_seo_url_thread
/printthread.php 124 get_thread_link
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.0.30 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.0.30 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key 1 - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1347 google_seo_url_cache
/inc/functions.php 5807 google_seo_url_profile
/inc/functions.php 5875 get_profile_link
/printthread.php 177 build_profile_link
Warning [2] Trying to access array offset on value of type null - Line: 833 - File: inc/plugins/google_seo/url.php PHP 8.0.30 (Linux)
File Line Function
/inc/plugins/google_seo/url.php 833 errorHandler->error
/inc/plugins/google_seo/url.php 1347 google_seo_url_cache
/inc/functions.php 5807 google_seo_url_profile
/inc/functions.php 5875 get_profile_link
/printthread.php 177 build_profile_link
Warning [2] Undefined array key "time" - Line: 2 - File: printthread.php(181) : eval()'d code PHP 8.0.30 (Linux)
File Line Function
/printthread.php(181) : eval()'d code 2 errorHandler->error
/printthread.php 181 eval



Computer Limbo
Java Tutorial: Get kinds of Coins from a money value - Printable Version

+- Computer Limbo (http://computerlimbo.com/forum)
+-- Forum: Computer Tech Support (http://computerlimbo.com/forum/Forum-computer-tech-support)
+--- Forum: Website Development (http://computerlimbo.com/forum/Forum-website-development--82)
+---- Forum: Java Programming (http://computerlimbo.com/forum/Forum-java-programming)
+---- Thread: Java Tutorial: Get kinds of Coins from a money value (/Thread-java-tutorial-get-kinds-of-coins-from-a-money-value)



Java Tutorial: Get kinds of Coins from a money value - TheWiz - 03-01-2011

This is a sample of how to use basic Java classes to return the amount of quarters, dimes, nickels, and pennies from any amount of money given.

Download source code: http://dl.dropbox.com/u/1525839/Java/TwoClasses2.zip

Coins.java (main class)
Code:
import java.util.Scanner;
import java.text.DecimalFormat;
public class Coins
{
    DecimalFormat twoDigits = new DecimalFormat("####");
    public static void main(String[] args)
    {
        menu();
    }
    public static void menu()
    {
        
        Scanner keyboard = new Scanner(System.in);
        double cents;
        System.out.println("\t1. Press One to calculate cents.");
        System.out.println("\t2. Exit program.");
        int choice = keyboard.nextInt();
        
        switch(choice)
        {
        case 1:
        {
            System.out.println("\n\n\nEnter amount of cents.");
            cents = keyboard.nextDouble();
            Calc instance01 = new Calc(cents);
            break;
        }
        case 2:
        {
            System.exit(0);
            break;
        }

        default:
        {
            menu();
            break;
        }
        }
        
    }
    public void recieveInfoCoinage(double q, double d, double n, double p)
    {
        System.out.println("Quarters: " + twoDigits.format(q));
        System.out.println("Dimes: " + twoDigits.format(d));
        System.out.println("Nickels: " + twoDigits.format(n));
        System.out.println("Pennies: " + twoDigits.format(p));
        menu();
    }

}import java.util.Scanner;
import java.text.DecimalFormat;
public class Coins
{
    DecimalFormat twoDigits = new DecimalFormat("####");
    public static void main(String[] args)
    {
        menu();
    }
    public static void menu()
    {
        
        Scanner keyboard = new Scanner(System.in);
        double cents;
        System.out.println("\t1. Press One to calculate cents.");
        System.out.println("\t2. Exit program.");
        int choice = keyboard.nextInt();
        
        switch(choice)
        {
        case 1:
        {
            System.out.println("\n\n\nEnter amount of cents.");
            cents = keyboard.nextDouble();
            Calc instance01 = new Calc(cents);
            break;
        }
        case 2:
        {
            System.exit(0);
            break;
        }

        default:
        {
            menu();
            break;
        }
        }
        
    }
    public void recieveInfoCoinage(double q, double d, double n, double p)
    {
        System.out.println("Quarters: " + twoDigits.format(q));
        System.out.println("Dimes: " + twoDigits.format(d));
        System.out.println("Nickels: " + twoDigits.format(n));
        System.out.println("Pennies: " + twoDigits.format(p));
        menu();
    }

}

Calc method (private subclass)
Code:
public class Calc extends Coins
{
    private double coinage, quarters, dimes, nickels, pennies;
    
    Calc(double cents)
    {
        coinage = cents;
        calculateCoinage();        
        
    }
    
    private void calculateCoinage()
    {
        if(coinage > 24)
        {
            quarters = Math.floor(coinage / 25);
            coinage = coinage - (quarters * 25);
        }
        if(coinage > 9)
        {
            dimes = Math.floor(coinage  / 10);
            coinage = coinage - (dimes * 10);
        }
        if(coinage > 4 )
        {
            nickels = Math.floor(coinage /5 );
            coinage = coinage - (nickels * 5);
        }

        pennies = coinage;
        Coins Coin01 = new Coins();
        Coin01.recieveInfoCoinage(quarters, dimes, nickels, pennies);
    }

}