Need some help.

Posts 1–9 of 9 · Page 1 of 1
Need some help.
Soon, I will be able to take AP computer science. Should I? If you've taken it, what was it like? I'm just worried it will be like some shitty "Scratch Class".
If it's anything like mine, it is nothing like Introduction to Programming... It's a serious class that actually challenges you.
Quote Originally Posted by liquidsystem View Post
If it's anything like mine, it is nothing like Introduction to Programming... It's a serious class that actually challenges you.
^ I heard the same thing so I didn't take it.
Quote Originally Posted by Bernard View Post


^ I heard the same thing so I didn't take it.
Well he also made a rage thread about learning Java...
Quote Originally Posted by liquidsystem View Post


Well he also made a rage thread about learning Java...
I don't like Java. But, I've done some small things in it. Anyways, thanks for answering. What do you mean by challenge though?
For my class we did Scratch for a few days and dived right into Java afterwards. I would take the class but my teacher is an expert so I may be biased.
Quote Originally Posted by ZeroInsanity View Post


I don't like Java. But, I've done some small things in it. Anyways, thanks for answering. What do you mean by challenge though?
"challenge" in the sense that it's new material that you get drilled into your head, you either learn it or fail.
GG NO RE

shit like this:
Code:
int numerator = (Math.abs(gen.nextInt()%ENDING_NUMBER) + STARTING_NUMBER);
or here's a fucking fantastic one...
 
extremely long

Code:
import javax.swing.JOptionPane;

public class bankTeller {

	// Scrum idea:
	/* Bank Teller program ---------
	 * Pre-Planning: make a list of pins, and give a balance to them to use
	 * 1. ask the user for their pin
	 * 2. check to see if the pin exists, if it does, find the variable associated with it
	 * 3. allow them to deposit, withdraw from their account
	 * 
	 */
	
	private static double account_balance;
	private static int pin;
	
	public static int[] getUsersList() 
	{
		int[] user = {1234, 2019, 2100, 1900, 1111, 0000};
		return user;
	}
	
	public static double[] getBalanceList()
	{
		double[] balance = {200, 5, 100, 10000, 1241.21, 5000};
		return balance;
	}
	
	public static void getPin()
	{
		boolean invalid_format = true;
		while(invalid_format)
		{
			String input = JOptionPane.showInputDialog("Please enter your Personal Identification Number","Enter your PIN");
			if(input==null)
			{
				System.exit(0);
			}
			try
			{
				pin = Integer.parseInt(input);
				invalid_format = false;
			}
			catch(NumberFormatException e)
			{
				JOptionPane.showMessageDialog(null,"I'm sorry, but it appears you did not enter a pin in the form of an integer.","Error",JOptionPane.ERROR_MESSAGE);
			}
		}
		setPin(pin);
	}
	
	public static void setPin(int p)
	{
		pin = p;
	}
	
	public static void welcome()
	{
		JOptionPane.showMessageDialog(null,"Good day! Welcome to the Bank of Middleton","Welcome!",JOptionPane.PLAIN_MESSAGE);
	}
	
	public static void preCheck()
	{
		getPin();
		boolean noPin = false;
		int i = 0;
		int[] users = getUsersList();
		double account_balance = 0.0;
		double[] balance = getBalanceList();
		JOptionPane.showMessageDialog(null,"Thank you for entering your pin, please hold while we check to see if your pin is correct...","Please Wait...",JOptionPane.PLAIN_MESSAGE);
		
		
		
		for(i=0;i<users.length;i++)
		{
			if(users[i] == pin)
			{
				account_balance=balance[i];
				noPin = false;
				break;
			}
			else
			{
				noPin = true;
			}
		}
		if(noPin == true)
		{
			JOptionPane.showMessageDialog(null,"It apppears that you have entered a pin that does not exist in our database. Try again.","Error",JOptionPane.ERROR_MESSAGE);
			preCheck();
		}
		
			setBalance(account_balance);
			createGUI();
	}
	
	public static void setBalance(double a)
	{
		account_balance = a;
	}
	
	public static void createGUI()
	{
		Object[] choices = {"Deposit","Withdraw","Go Back"};
		int choice = JOptionPane.showOptionDialog(null,"Hello! What would you like to do with your account?"+"\nYour current balance is: $"+account_balance,"Account",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,choices,choices[0]);
		if(choice==0) // User has chosen deposit
		{
			deposit(account_balance);
			JOptionPane.showMessageDialog(null,"Your new balance: $"+account_balance,"Balance",JOptionPane.PLAIN_MESSAGE);
		}
		else if(choice==1)
		{
			withdraw(account_balance);
			JOptionPane.showMessageDialog(null,"Your new balance is: $"+account_balance,"Balance",JOptionPane.PLAIN_MESSAGE);
		}
		else if(choice==2)
		{
			account_balance = 0;
			pin = 0;
			preCheck();
		}
		else
		{
			System.exit(0);
		}
		
	}
	
	public static void deposit(double user_input)
	{
		double addMoney=checkNumber(user_input,"add"); 
		account_balance+=addMoney;
		createGUI();
	}
	
	public static void withdraw(double user_input)
	{
		double removeMoney=checkNumber(user_input,"remove");
		if(removeMoney > account_balance)
		{
			JOptionPane.showMessageDialog(null,"I'm sorry, but you cannot withdraw more than you have in your account","Error",JOptionPane.ERROR_MESSAGE);
			withdraw(account_balance);
		}
		else
		{
			account_balance-=removeMoney;
			createGUI();
		}
	}
	public static double checkNumber(double user_input,String addOrRemove)
	{
		boolean invalid = true;
		double changeMoney = 0;
		while(invalid)
		{
			String input = JOptionPane.showInputDialog(null, "How much money would you like to "+ addOrRemove +" to your account?",addOrRemove+" Money",JOptionPane.PLAIN_MESSAGE);
			try
			{
				changeMoney = Double.parseDouble(input);
				invalid = false;
			}
			catch(NumberFormatException e)
			{
				JOptionPane.showMessageDialog(null,"Sorry, you did not enter a proper number.","Error",JOptionPane.ERROR_MESSAGE);
			}	
		}
		
		changeMoney = Math.abs(changeMoney);
		return changeMoney;
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		welcome();
		preCheck();
	}

}


- - - Updated - - -

Quote Originally Posted by Cataclypse View Post
For my class we did Scratch for a few days and dived right into Java afterwards. I would take the class but my teacher is an expert so I may be biased.
Sounds like Intro to me...
In Advanced (Or AP...) the teacher assumes you know what the fuck you're doing and know what an IDE is, so we began with a simple number guessing game.
I am interested in this as-well, I just started C++ :P
I'm taking the test this May for it.

I recommend it if you can have a good grasp of programming logic and mathematics.
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us