//***************************************************** // Account.java // // A class representing a bank account; allows deposits, // withdrawals, balance inquiries, etc. //***************************************************** public class Account { private double balance; private String name; private long acctNum; //--------------------------------------------------- // Constructor -- initializes instance data //--------------------------------------------------- public Account(double initBal, String owner, long number) { balance = initBal; name = owner; acctNum = number; } //--------------------------------------------------- // Simple withdrawal -- deducts amount from balance // If balance doesn't cover withdrawal, prints message // and does not change balance. //--------------------------------------------------- public void withdraw(double amount) { if (balance >= amount) balance -= amount; else System.out.println("Insufficient funds"); } //--------------------------------------------------- // Simple deposit -- adds amount to balance. //--------------------------------------------------- public void deposit(double amount) { balance += amount; } //--------------------------------------------------- // Returns balance. //--------------------------------------------------- public double getBalance() { return balance; } //--------------------------------------------------- // Prints name, account number, and balance //--------------------------------------------------- public void printSummary() { //print name _____________________________ //print acct number _____________________________ //print balance _____________________________ } //--------------------------------------------------- // Deducts $10 service fee if balance is under $1000 //--------------------------------------------------- public void chargeFee() { } //--------------------------------------------------- // Changes the name on the account to newName. //--------------------------------------------------- public void changeName(String newName) { } }
//***************************************************** // ManageAccounts.java // // A program that uses the Account class to create and // manipulate bank accounts for Sally and Joe. //***************************************************** public class ManageAccounts { public static void main(String[] args) { Account account1, account2; //create account1 for Sally for $1000 account1 = new Account(1000, "Sally", 12345); //create account2 for Joe with $500 ______________________________________________ //deposit $100 to Joe's account ______________________________________________ //withdraw $50 from Sally's account ______________________________________________ //charge fees to both accounts ______________________________________________ ______________________________________________ //change name on Joe's account to Joseph ______________________________________________ //print summary for both accounts ______________________________________________ ______________________________________________ } }
//***************************************************** // Student.java // // A class representing a student; holds info about // the student's name and test grades. //***************************************************** public class Student { //declare instance data __________________________ // name __________________________ // grade for test #1 __________________________ // grade for test #2 //--------------------------------------------------- // Constructor -- creates a student object whose name // is the value passed in. //--------------------------------------------------- public Student(String studentName) { } //--------------------------------------------------- // inputGrades: Prompts for and reads in grades for // the student's two tests. No parameters or return value. //--------------------------------------------------- public void inputGrades() { ... body of inputGrades ...(don't fill in) } //--------------------------------------------------- // printName: Prints the student's name. No parameters // or return value. //--------------------------------------------------- ____________________________________ //fill in header { ... body of printName ...(don't fill in) } //--------------------------------------------------- // getAverage: Computes and return the average of the // student's test grades. No parameters. //--------------------------------------------------- ____________________________________ //fill in header { ... body of getAverage ... (don't fill in) } }