Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Hey this is my first time posting on here. Brand new to Java and i can't get it to complile correctly. The point of this program is to do banking for the user whom is using the program. We were giving code to fix and correct. These are the things that must be in the program...

    Must List:
    1. break the program up into method
    2. do error detection and correction - try..catch
    3. use a switch statement instead of if() statements
    4. prevent user from withdrawing more money that he has
    5. Must work correctly
    6. Must use a do.. while or a while() loop
    7. Must run in a GUI environment, i.e., can't use System.out.println() statements on final version.
    8. Must make the prompts easier for the user to continue




    import javax.swing.*;
    import javax.swing.JOptionPane;
     
    public class MiniLab5
    {
     
    	static double balance = 0;
    	static double newBalance = 0;
    	static double adjustment = 0;
     
    	String response;
    	String moreBankingBusiness;
     
    	public static void main (String[] args)
    	{
     
        public static void runIt()
        {
     
     
     
    	moreBankingBusiness = JOptionPane.showInputDialog
    		( "Do you want to do some banking?" );
     
    	moreBankingBusiness = moreBankingBusiness.toUpperCase();
        	openingMessage();
     
     
        } // runIt
     
     
     
        public static int openingMessage()
     
        {
        	String  openingMessage = "";
        	openingMessage = "***WELCOME TO SMILEY NATIONAL BANK*** \n\n"   // change my Message to
    	                       + "Atm may charge a surcharge fee \n \n";
     
     
             JTextArea outputArea = new JTextArea(5,10);  // create an Instance of a JTextArea - in this case the variable name is outputArea
     
    	     outputArea.setText ( openingMessage );  // put the Text String into the outputArea
     
    	     JOptionPane.showMessageDialog ( null, outputArea,  // Display the Message
                 "Smiley National Bank",           // Create a suitable Title for the Window
    		       JOptionPane.INFORMATION_MESSAGE );
     
     
     
     
    	while (moreBankingBusiness.equals ("YES"))
    	{
    		int response; 
     
    	    response = JOptionPane.showInputDialog
    		( "What would you like to do? (1=Deposit, 2=Withdraw, 3=Get Balance)");
    	    if (response == null)
    	    {
    			JOptionPane.showMessageDialog
    				(null, "You clicked on the Cancel button");
    			System.exit (0);
    	    } // if
    	   else
    	      if (response.equals(""))
    	     {
    			JOptionPane.showMessageDialog
    				(null, "You must make an entry in the InputBox");
    			System.exit (0);
    	    } // else if
    	     else
    	       if (Integer.parseInt(response) < 1 | Integer.parseInt(response) > 3)
    	       {
         			JOptionPane.showMessageDialog
    				(null, response + " - is not a valid student type");
    			System.exit (0);
    	      } // else if
     }// openingMessage
    //1 is a Deposit
     
    	     if (Integer.parseInt(response) == 1)
    	    {
    		     adjustment = Double.parseDouble
    		     		(JOptionPane.showInputDialog( "Enter the Deposit Amount" ));
     
    		    newBalance = balance + adjustment;
     
    		    JOptionPane.showMessageDialog
    			(null, "*** SMILEY NATIONAL BANK ***\n\n" +
    			"Old Balance is: " + balance + "\n" +
    			"Adjustment is: +" + adjustment + "\n" +
    			"New Balance is: " + newBalance + "\n");
    	   } // if
     
    //2 is a Withdrawal
          if (Integer.parseInt(response) == 2)
          {
    	    	adjustment = Double.parseDouble
        			(JOptionPane.showInputDialog( "Enter the Withdrawal Amount" ));
     
        		newBalance = balance - adjustment;
     
    	    	JOptionPane.showMessageDialog
    			    (null, "*** SMILEY NATIONAL BANK ***\n\n" +
    			     "Old Balance is: " + balance + "\n" +
    			     "Adjustment is: -" + adjustment + "\n" +
    			    "New Balance is: " + newBalance + "\n");
         } // if
     
    // 3 is a balance inquiry
    	if (Integer.parseInt(response) == 3)
    	{
    			JOptionPane.showMessageDialog
    			(null, "*** SMILEY NATIONAL BANK ***\n\n" +
    			"Your Current Balance Balance is: " + balance );
    	}// if
     
           balance = newBalance;
    	   moreBankingBusiness = JOptionPane.showInputDialog
    		  ( "Do you have more banking business?" );
    	   moreBankingBusiness = moreBankingBusiness.toUpperCase();
      }	// end of while
     
     
     
    	JOptionPane.showMessageDialog(null, "Thanks for banking with us!");
    	System.exit (0);
     
     }				// end of main
    }						// end of class


    Any Help is greatly appriciated.
    P.S. I realize it doesn't compile....my code should indicate im a noob.
    Last edited by chatok90; November 28th, 2011 at 08:14 PM. Reason: Forgot to do the highlight command sorry


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Do not impose your time constraints on us. It is your deadline not ours. We will answer you if and when we like.

    Ask a specific question and get a specific answer. If your code doesn't compile then include the exact error messages.
    Improving the world one idiot at a time!

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Please see the link in my signature entitled 'Getting Help'. It has advice within that will help you phrase your questions and posts to maximize your chances of getting help.

  4. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Sorry not trying to rush anyone just didn't want anyone to solve it after the date i had to have it done by. But anyways i keep getting an "error: illegal start of expression" on lines 18 and 38. Actually it is two of the same error messages on line 18 and 38. Then also i'm getting " error: ; expected" errors on lines 18 and 38. It seems every time i try to create a method in this program it give me an error. Thank you again to anyone who take the time to help me out with this

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Which are lines 18 and 38?
    Improving the world one idiot at a time!

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Make sure your methods are NOT inside of other methods.
    Check for correctly paired {}s

  7. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Line 18 is public static void runIt ()


    Line 38 is public static void openingMessage()

  8. #8
    Junior Member
    Join Date
    Nov 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    can you rate your professor on ratemyprofessor.com so nobody else takes him ever again?

    and to be on topic you could start by actually calling your runIt(); method in the main and closing the brackets for main after calling it. all the static functions need to be outside.

  9. #9
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    can you rate your professor on ratemyprofessor.com so nobody else takes him ever again?
    It's always easy to blame others for nothing. What if OP's Professor has already told him/her everything before and OP is not quite interested in lectures and when it came to assignment, just for the sake of help, put his problem over the forums by simply blaming or saying that it's his very first class or blah blah....

    Well, programming is an art, you don't need teachers. Internet is the best source to start on.

  10. #10
    Member
    Join Date
    Mar 2011
    Posts
    198
    My Mood
    Daring
    Thanks
    7
    Thanked 4 Times in 4 Posts

    Default Re: Simple Java Homework : Due Wendsday Afternoon PLZ HELP!

    Quote Originally Posted by Mr.777 View Post
    You don't need teachers. Internet is the best source to start on.
    I totally agree... I have just finished programming in college. I knew more then the teacher, Our last assignment was a multi threaded chat.. Seems the teacher didn't want to teach us networking. Told us to go Google it ourselves.. and that's why i officially hate college lol

Similar Threads

  1. JAVA HOMEWORK HELP!
    By javafirsttime in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 14th, 2011, 07:00 PM
  2. Pleasant morning/afternoon/evening to everyone! Newbie here.
    By enzoflores in forum Member Introductions
    Replies: 1
    Last Post: November 8th, 2011, 12:32 AM
  3. New to Java Need help with Homework
    By cjg2283 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 20th, 2011, 09:47 PM
  4. help with homework - simple arrays
    By sensoryctascale in forum Java Theory & Questions
    Replies: 3
    Last Post: April 5th, 2011, 01:39 AM
  5. Good Morning/Day/Afternoon/Evening/Night
    By K0209 in forum Member Introductions
    Replies: 3
    Last Post: January 4th, 2010, 11:26 AM