Design an application that declares an array of 20 AutomobileLoan objects. Prompt the user for data for each object, and then pass the array to a method that determines the sum of the balances.
import java.util.Scanner;
public class AutomobileLoan{
private String username;
private double loanAmount, repaid;
private String carModel, color;
private int yearMake;
public AutomobileLoan(){
}
public AutomobileLoan(String username, double
loanAmount, double repaid, String carModel, String color, int
yearMake) {
this.username = username;
this.loanAmount = loanAmount;
this.carModel = carModel;
this.color = color;
this.yearMake = yearMake;
this.repaid = repaid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public double getLoanAmount() {
return loanAmount;
}
public void setLoanAmount(double loanAmount)
{
this.loanAmount = loanAmount;
}
public String getCarModel() {
return carModel;
}
public void setCarModel(String carModel) {
this.carModel = carModel;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getYearMake() {
return yearMake;
}
public void setYearMake(int yearMake) {
this.yearMake = yearMake;
}
public double getRepaid() {
return this.repaid;
}
public static void totalLoan(AutomobileLoan[] cars,
int count) {
double amount = 0.0;
for(int i = 0 ; i < count ;
i++)
{
amount +=
(cars[i].getLoanAmount() - cars[i].getRepaid());
}
System.out.println("Total loan
amount is: " + amount);
}
public static void main(String[] args) {
Scanner scanner = new
Scanner(System.in);
AutomobileLoan[] loan = new
AutomobileLoan[20];
int count;
String name, color, model;
int year;
double loanAmount, repaid;
System.out.print("Enter the number
of loan information you want to insert: ");
count = scanner.nextInt();
for(int i = 0 ; i < count ;
i++)
{
System.out.println("Applicant " + (i+1));
System.out.print("Enter applicant's name: ");
name =
scanner.next();
System.out.print("Enter car model: ");
model =
scanner.next();
System.out.print("Enter car color: ");
color =
scanner.next();
System.out.print("Enter year make: ");
year =
scanner.nextInt();
System.out.print("Enter loan amount: ");
loanAmount =
scanner.nextDouble();
System.out.print("Enter amount repaid against loan: ");
repaid =
scanner.nextDouble();
loan[i] = new
AutomobileLoan(name, loanAmount, repaid, model, color, year);
System.out.println("---------------------------");
}
AutomobileLoan.totalLoan(loan,
count);
scanner.close();
}
}
Output:
![<terminated> AutomobileLoan [Java Application] C\Program FilesJava\jdk-12.0.1\bin\javaw.exe (Aug 14, 2019, 10:46:20 PM) Enter](http://img.homeworklib.com/questions/18f3d520-a10b-11ea-a2e8-2be2a2313646.png?x-oss-process=image/resize,w_560)
Design an application that declares an array of 20 AutomobileLoan objects. Prompt the user for data...
Design a class named StockTransaction that holds a stock symbol (typically one to four characters), stock name, and price per share. Include methods to set and get the values for each data field. Design an application that declares two StockTransaction objects and sets and displays their values. Design an application that declares an array of 15 StockTransaction objects. Prompt the user for data for each object, and then display all the values. Design an application that declares an array of...
Write a console application in c# that uses a one dimensional array; prompt the user to enter letters, ( a, b, c, … z). As each letter is input, store it in the array only if it is not a duplicate of previous letters entered. After 7 unique letters have been entered, display the unique values in the array. Be sure to test with duplicate values.
Design a program that prompt the user to enter 10 integer numbers into an array. Program should print the numbers in a reverse order (flowchart) c++
C# Create an application named JobDemo that declares and uses Job objects. The Job class holds job information for a home repair service. The class has five properties that include: JobNumber - The job number Customer - The customer name Description - The job description Hours - The estimated hours price - The price for the job Create a constructor that requires parameters for all the data except price. Include auto-implemented properties for the job number, customer name, and job...
For this assignment you will be creating an array of objects or a list of objects of car parts based on user input. 1. Create a Parts class with the following items a. Properties for PartNum, Part Name, Part Description, and Cost b. Must have a constructor 2. In the main you will need accomplish the following: a. Ask the user how many objects they wish to enter b. Create an array of parts objects c. Loop appropriately to collect...
create a new Java application called "MinMax" (without the quotation marks) that declares an array of doubles of length 5, and uses methods to populate the array with user input from the command line and to print out the max (highest) and min (lowest) values in the array.
a. Create a class named Lease with fields that hold an apartment tenant's name, apartment Number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name. "XXX", the apartment number to O, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy...
create a new Java application called "Scorer" (without the quotation marks) that declares a two-dimensional array of doubles (call it scores) with three rows and three columns and that uses methods and loops as follows. Use a method containing a nested while loop to get the nine (3 x 3) doubles from the user at the command line. Use a method containing a nested for loop to compute the average of the doubles in each row. Use a method to...
C++ Program 1. Create a class named BaseballGame that has fields for two team names and a final score for each team. Include methods to set and get the values for each data field. Your application declares an array of 12 BaseballGame objects. Prompt the user for data for each object, and display all the values. Then pass each object to a method that displays the name of the winning team or “Tie” if the score is a tie. (main.cpp,...
Three C Code Questions: 5. Write a C program that declares an array of 10 strings, each of max length 50 characters, and then reads an entire line of text from the keyboard into each string. 6. Write C code that finds the longest name in this array of strings that you read in Q5. Hint: find the position of the longest string, not the string itself. 7. Write a C program that creates a 4 x 6 two dimensional...