11.3
/*
* Class for Account
*/
import java.util.Date;
public class Account {
private String accountNumber;
private double balance;
private double intrestRate;
private Date dateCreated;
// constructor
public Account(String accountNumber, double
balance, double intrestRate) {
this.accountNumber =
accountNumber;
this.balance =
balance;
this.intrestRate =
intrestRate;
this.dateCreated = new
Date();
}
public double getBalance() {
return balance;
}
public void setBalance(double balance)
{
this.balance =
balance;
}
// method to deposit amount
public void deposit(double amount){
balance = balance +
amount;
System.out.println("Deposited "+amount);
}
// method to withdraw amount
public void withdraw(double amount){
// withdraw only if
there is sufficient balance
if(balance>=amount){
balance = balance - amount;
System.out.println("Withdrawed "+amount);
}
else
System.out.println("No enough balance");
}
public String toString() {
return "AccountNumber: "
+ accountNumber + "\nBalance:" + balance + "\nIntrestRate=" +
intrestRate + "\nDateCreated=" + dateCreated+"\n";
}
}
/*
* Class for checking account
*/
public class CheckingAccount extends Account{
private double overDraftLimit;
public CheckingAccount(String accountNumber,
double balance, double intrestRate, double odLimit) {
super(accountNumber,
balance, intrestRate);
overDraftLimit =
odLimit;
}
public String toString() {
return super.toString()
+ "OverDraftLimit:" + overDraftLimit + "\n";
}
// method to withdraw amount
public void withdraw(double amount){
// withdraw only if
there is sufficient balance
if((getBalance()+overDraftLimit)>=amount){
setBalance(getBalance()- amount);
System.out.println("Withdrawed "+amount);
}
else
System.out.println("No enough balance");
}
}
/*
* Class for savings account
*/
public class SavingsAccount extends Account{
public SavingsAccount(String accountNumber,
double balance, double intrestRate) {
super(accountNumber,
balance, intrestRate);
}
}
/*
* Class to test
*/
public class TestProgram {
public static void main(String[] args) {
//create objects
Account a = new
Account("12345", 100, 5);
CheckingAccount c = new
CheckingAccount("34534", 100, 3,
100);
SavingsAccount s = new
SavingsAccount("67687", 100, 5);
// do operations and
display account details
a.withdraw(100);
a.deposit(100);
System.out.println(a.toString());
c.withdraw(200);
c.deposit(500);
System.out.println(c.toString());
s.withdraw(200);
s.deposit(500);
System.out.println(s.toString());
}
}
OUTPUT

UML class diagram

11.9
/*
* Program to randomnly fill array with 1 or 0 into nxn array,
* print array and find rows and columns with most 1's
*/
import java.util.ArrayList;
import java.util.Scanner;
public class LargestRowCol {
public static void main(String[] args)
{
Scanner in = new
Scanner(System.in);
System.out.print("Enter
array size: ");
int size =
in.nextInt();
int[][] randomArray =
new int[size][size];
// loop to fill
array
for (int i = 0; i <
size; i++) {
for (int j = 0; j < size; j++) {
// create random 0 or 1
int num = (int)Math.round( Math.random() ) ;
randomArray[i][j] = num;
}
}
// loop to display
array
for (int i = 0; i <
size; i++) {
for (int j = 0; j < size; j++) {
System.out.print(randomArray[i][j]+" ");
}
System.out.println();
}
// variables to store
number of 1's
ArrayList<Integer>
rowIndex = new ArrayList();
ArrayList<Integer>
columIndex = new ArrayList();
int largestRow=0,
largestCol=0;
int count;
// loop to count and
store number of 1's in each row
for (int i = 0; i <
size; i++) {
count = 0;
for (int j = 0; j < size; j++) {
if(randomArray[i][j]==1)
count++;
}
if(count>largestRow)
largestRow = count;
rowIndex.add(count);
}
// loop to count and
store number of 1's in each column
for (int j = 0; j <
size; j++) {
count = 0;
for (int i = 0; i < size; i++) {
if(randomArray[i][j]==1)
count++;
}
if(count>largestCol)
largestCol = count;
columIndex.add(count);
}
// Display largest
rows
System.out.print("The
largest row index: ");
for(int i=0;
i<rowIndex.size(); i++){
if(rowIndex.get(i)==largestRow)
System.out.print(i+" ");
}
// Display largest
colums
System.out.print("\nThe
largest column index: ");
for(int i=0;
i<columIndex.size(); i++)
if(columIndex.get(i)==largestCol)
System.out.print(i+" ");
}
}
OUTPUT

11.13
/*
* Program to remove duplicate values from integer list
*/
import java.util.ArrayList;
import java.util.Scanner;
public class RemoveDuplicate {
public static void main(String[] args)
{
Scanner in = new
Scanner(System.in);
System.out.print("Enter
10 integers: ");
ArrayList<Integer>
list = new ArrayList<Integer>();
// read integers as
string
String input =
in.nextLine();
// split the string by
space
String[] integers =
input.split(" ");
// add integer to
list
for(int i=0;
i<integers.length; i++) {
list.add(Integer.parseInt(integers[i]));
}
// remove
duplicate
removeDuplicate(list);
// print list
System.out.print("The
distinct integers are ");
for (int i = 0; i <
list.size(); i++) {
System.out.print(list.get(i)+" ");
}
System.out.println("");
}
// method to remove duplicate
private static void
removeDuplicate(ArrayList<Integer> list){
for (int i = 0; i <
list.size(); i++) {
for (int j = i + 1; j < list.size(); j++) {
if (list.get(i) == list.get(j)) {
list.remove(j);
j--;
}
}
}
}
}
OUTPUT

11.3 (Subclasses of Account) In Programming Exercise 9.7, the Account class was defined to model a...
this language is JAVA
2. Design a class named Location for locating a maximum value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two-dimensional array with row and column as int types and maxValue as a double type. Write the following method that returns the location of the largest element in a two-dimensional array: Public static Location locateLargest(double [][] a) Create...
SOLVE IN PYTHON: Exercise #2: Develop a program (name it LocateLargestElement) that prints out the location of the first largest value in a two-dimensional array. The largest values may appear more than once in the array. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints out...
IN JAVAThe code is attached below has the Account class that was designed to model a bank account. An account has the properties account number, balance, annual interest rate, and date created, and methods to deposit and withdraw funds. I need creat program using the 2 java programs.Create two subclasses for checking and savings accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn.I need to write a test program that creates objects of Account,...
This needs to be in python, however, I am having trouble with the code. Is there any way to use the code that I already have under the main method? If so, what would be the rest of the code to finish it? #Create main method def main(): #Create empty list list=[] #Display to screen print("Please enter a 3 x 4 array:") #Create loop for rows and have each entered number added to list for i in range(3): list.append([int(x) for...
(Remove duplicates) Write a method that removes the duplicate elements from an array list of integers using the following header: public static void removeDuplicate(ArrayList < Integer > list) Write a test program that prompts the user to enter 10 integers to a list and displays the distinct integers in their input order separated by exactly one space. Sample Run 1 Enter ten integers: 34 5 3 5 6 4 33 2 2 4 The distinct integers are 34 5 3...
IN C#.Develop a program that prints out the location of the largest value in a two-dimensional array. The largest values may appear more than once in the array, so you must only print out the first instance. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints...
Write C++ programs that create TEN(10) different N*N magic squares. A square matrix is the arrangement of the numbers 1, 2, ., N2, in which the sum of rows, columns, and diagonals are the same. The users (i.e., TAs) will specify the size of the square matrix: N. The value N must be an odd number between 3 and 15. Example Run For example, you program is expected to run as the following way. NOTE: We only list 5 magic...
Create a class called Lab7b and in it implement all of the methods below. Also, write a main method with test calls to all of these methods. Don’t forget to turn in your file to Canvas before the end of the lab today. int[][] random(int N, int start, int end) returns an N-by-N matrix of random integers ranging from start to end; int rowSum(int[][] a, int i) returns the sum of the elements in row i of the 2-D array...
Design and implement a Java class (name it SummerStats.java) that tracks statistics for summer job salaries for a group of people over several years. The only data field you need is a 2-Dimenssional array of values representing salaries. The rows the represents the people and the columns represent the years. The constructor method takes two integers representing the number of people and the number of years, then randomly generates the annual salaries and fills the array. Other class methods include...
Design and implement a Java class (name it Summer Stats. java) that tracks statistics for summer job salaries for a group of people over several years. The only data field you need is a 2-Dimenssional array of values representing salaries. The rows the represents the people and the columns represent the years. The constructor method takes two integers representing the number of people and the number of years, then randomly generates the annual salaries and fills the array. Other class...