Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 132,634 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,054 people online right now. Registration is fast and FREE... Join Now!




Java Program - Initialized Variable Error

 
Reply to this topicStart new topic

Java Program - Initialized Variable Error

BigMike7319
post 12 Oct, 2008 - 08:09 AM
Post #1


New D.I.C Head

*
Joined: 12 Oct, 2008
Posts: 14

Hello all, I am having an issue with a program I am currently writing. I keep getting an
error saying that the variables arn't initilazed....but I did initialize them after I declaired them.
I'm really not sure what the heck I am doing wrong, If someone could take a look at this and
give me some insight as to what I did wrong I would greatly appricate it.

Here is my code;

CODE


/*
    Programmer:    Micheal W. Smith

    Date:        October 8, 2008

    Purpose:    Write a Java Program that Prompts the User to enter number of quaters
                    number of dimes, number of nickles, and number of pennies. The program
        will add the coins and give the user the total for the coins entered by
        the user in dollars and cents.
*/
import java.util.Scanner;

public class money

{

    public static void main(String [] args)

        {

            //Declaring Variables

            int quarters;
            int dimes;
            int nickels;
            int pennies;
            int dollars;
            double TotalAmount = 0.0;

            //Initializing
            quarters = quarters * 25;
            dimes = dimes * 10;
            nickels = nickels * 5;
            pennies = pennies * 100;


            Scanner keyboard = new Scanner(System.in);

            //Input prompt from user

            System.out.println("Enter the numbers of Quaters ");
            quarters= keyboard.nextInt();


            System.out.println("Enter the number of Dimes ");
            dimes = keyboard.nextInt();


            System.out.println("Enter the number of Nickles");
            nickels = keyboard.nextInt();

            System.out.println("Enter the number of pennies");
            pennies = keyboard.nextInt();

            //algorythm used in final calculation
            TotalAmount = quarters + dimes + nickels + pennies;


            System.out.println("Your Dollar Amount is " + TotalAmount);

       }



}


User is offlineProfile CardPM

Go to the top of the page

BigMike7319
post 12 Oct, 2008 - 09:16 AM
Post #2


New D.I.C Head

*
Joined: 12 Oct, 2008
Posts: 14

Figured it out!!! Ignore the post, I got it, such a simple mistake crazy.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 04:06AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month