Ch3 classwork notes - Ch3 classwork notes 1 import...

Info icon This preview shows pages 1–3. Sign up to view the full content.

Ch3 classwork notes 1. import javax.swing.JOptionPane; public class BankAccount { private double balance ; public BankAccount() // default constructor { balance =0; } public BankAccount( double iniBal) //mutator constructor { balance = iniBal; } public void deposit( double amt) { balance = balance + amt; } public void withdraw( double amt) { balance = balance - amt; } public double getBalance() { return balance ; } public void display() { String message= "The balance is " + balance ; JOptionPane. showMessageDialog ( null , message); } } 2. public class useBankAccount { public static void main(String[] args) { BankAccount Laura = new BankAccount(); BankAccount Christina = new BankAccount(1000); Laura. deposit(500); Christina. deposit(1000); Laura.withdraw(500); Christina.withdraw(200); Laura.display(); Christina.display(); } }
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

3. student.java public class student { private String id ; private String name ; private double gpa ; public student() // default constructor { id = "AAAA" ; name = "Jane Doe" ; gpa = 0; } public student( String id1, String n, double g){ id = id1; name = n; gpa =g; } public void display() { System. out .println( name + " ID number is " + id + " has gpa of " +
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '10
  • Silou
  • SEPTA Regional Rail, Automobile, Jaguar Racing, public class

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern