EATULAB
EATULAB
Modify class Account to provide a method called withdraw that withdraws money from an
account. Ensure that withdrawal amount doesn’t exceed the Account’s balance. If it does, the
balance should be left unchanged and the method should print a message indicating “Withdrawal
amount exceeded account balance”. Modify class AccountTest to test method withdraw.
Account Class
Package BankAccess;
AccountTest Class
Package BankAccess;
import java.util.Scanner;
public class AccountTest {
public static void main(String[] args) {
System.out.println();
System.out.println();
System.out.print("Enter withdraw amount for account2: ");
withdrawAmount = input.nextDouble();
System.out.println();
}
}
}
Statement
Create a class called Employee that includes three instance variables – a first name
(type String), a last name (type String) and a monthly salary (double). Provide a
constructor that initializes the three variables. Provide a set and get method for each
instance variable. If the monthly salary isn’t positive, don’t set its value. Write a test app
named EmployeeTest that demonstrates class Employee’s capabilities. Create 2
Employee object and display each object’s yearly salary. Then give each employee a
10% raise and display each employee’s yearly salary again
Employee Class
package OfficeSalary;
EmployeeTest Class
package OfficeSalary;
import java.util.Scanner;
employee1.setSalary(newSalary1);
System.out.printf("New yearly salary for %s is: $%.2f%n", employee2.getFullName(),
employee2.getSalary());
System.out.printf("%nSet new salary for %s: ", employee2.getFullName());
double newSalary = input.nextDouble();
employee2.setSalary(newSalary);
System.out.printf("New yearly salary for %s is: $%.2f%n", employee2.getFullName(),
employee2.getSalary());
Calculator code
import java.io.InputStream;
import java.util.Scanner;
public class Calculator {
if (x=='+')
System.out.printf("%d ",a+b);
else
if (x=='-')
System.out.printf("%d ",a-b);
else
if (x=='*')
System.out.printf("%d ",a*b);
else
if (x=='/')
System.out.printf("%d ",a/b);
else
if (x=='%')
System.out.printf("%d ",a%b);
else
System.out.println("try again");
}
}
Grade average
import java.util.Scanner;
}
Sumation of number
import java.util.Scanner;