Question

In: Computer Science

C# windows application form. Create a base class to store characteristics about a loan. Include customer...

C# windows application form. Create a base class to store characteristics about a loan. Include customer details in the Loan base class such as name, loan number, and amount of loan. Define subclasses of auto loan and home loan. Include unique characteristics in the derived classes. For example you might include details about the specific auto in the auto loan class and details about the home in the home loan class. Create a presentation class to test your design by displaying information about both types of loans

Solutions

Expert Solution

using System;

class Loan
{
   //data variables
   private string customerName;
   private int loanNumber;
   private double amount;
   //constructor
   public Loan(){}
   public Loan(string customerName,int loanNumber,double amount)
   {
       this.customerName = customerName;
       this.loanNumber = loanNumber;
       this.amount = amount;
      
   }
   //properties
   public String CustomerName
   {
       set{customerName = value;}
       get{return customerName;}
   }
   public int LoanNumber
   {
       set{loanNumber = value;}
       get{return loanNumber;}
   }
   public double Amount
   {
       set{amount = value;}
       get{return amount;}
   }
  
}
class AutoLoan:Loan
{
   private int autoNumber;
   private String make;
  
   //constructor
   public AutoLoan(){}
   public AutoLoan(string customerName,int loanNumber,double amount,int autoNumber,String make):base(customerName,loanNumber,amount)
   {
       this.autoNumber = autoNumber;
       this.make = make;
   }
   //properties
   public int AutoNumber
   {
       set{autoNumber = value;}
       get{return autoNumber;}
   }
   public String Make
   {
       set{make = value;}
       get{return make;}
   }
}
class HomeLoan:Loan
{
   private string homeAddress;
  
   //constructor
   public HomeLoan(){}
   public HomeLoan(string customerName,int loanNumber,double amount,string homeAddress): base(customerName,loanNumber,amount)
   {
       this.homeAddress = homeAddress;
   }
  
   //properties
   public String HomeAddress
   {
       set{homeAddress = value;}
       get{return homeAddress;}
   }
}
public class Test
{
   public static void Main()
   {
       Console.WriteLine("Enter Customer Name : ");
       string cname = Console.ReadLine();
       Console.WriteLine("Enter Loan Number : ");
       int lno = Convert.ToInt32(Console.ReadLine());
       Console.WriteLine("Enter Amount : ");
       double amount = Convert.ToDouble(Console.ReadLine());
       Console.WriteLine("Enter the type <1:Auto Loan 2: Home Loan>");
       int type = Convert.ToInt32(Console.ReadLine());
      
       if(type ==1)
       {
       Console.WriteLine("Enter Auto Number : ");
       int autono = Convert.ToInt32(Console.ReadLine());
       Console.WriteLine("Enter make : ");
       string make = Console.ReadLine();
       AutoLoan al = new AutoLoan(cname,lno,amount,autono,make);
       Console.WriteLine("Auto Loan Details :"+al.CustomerName + "\nloan number :"+al.LoanNumber +"\nAmount :"+ al.Amount+"\nAuto Number :"+al.AutoNumber +"\nMake :"+al.Make);
       }
       else if(type == 2)
       {
       Console.WriteLine("Enter home address : ");
       string haddress = Console.ReadLine();
       HomeLoan hl = new HomeLoan(cname,lno,amount,haddress);
       Console.WriteLine("Home Loan Details :"+ "\ncustomer:"+hl.CustomerName + "\nloan number :"+hl.LoanNumber +"\nAmount :"+ hl.Amount+"\nHome address :"+ hl.HomeAddress);
       }
       else
       Console.WriteLine("Wrong type");
      
      
   }
}

output:

Enter Customer Name : John Smith
Enter Loan Number : 87655
Enter Amount : 12000
Enter the type  <1:Auto Loan  2: Home Loan>
Enter home address : #23,hillside,NJ
Home Loan  Details :

customer:John Smith loan number :87655 Amount :12000 Home address :#23,hillside,NJ


Related Solutions

Create a Windows application in C# that can be used to change the form color. Your...
Create a Windows application in C# that can be used to change the form color. Your form background color should initially be blue. Provide at least two buttons with two different color choices and a Reset option. Change the font style and size on buttons. Align the buttons so that they are in the center of the form. The color choice buttons should be the same size. Add event handlers for the buttons so that when the user click the...
Create a windows form application in C# that looks and functions like a basic calculator. It...
Create a windows form application in C# that looks and functions like a basic calculator. It must do the following: Add, subtract, multiply, and divide. Account for division by zero. Show at least two decimal places. Retain the last number on the window so that, when the user opens the calculator the next time, the number that was in the window at the last close appears. Have a memory, so that users can store values and recall them. Operate with...
Create a Class to contain a customer order Create attributes of that class to store Company...
Create a Class to contain a customer order Create attributes of that class to store Company Name, Address and Sales Tax. Create a public property for each of these attributes. Create a class constructor without parameters that initializes the attributes to default values. Create a class constructor with parameters that initializes the attributes to the passed in parameter values. Create a behavior of that class to generate a welcome message that includes the company name. Create a Class to contain...
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App...
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App that has more than one form, like say maybe 5 forms. How do you connect these forms and pass data objects between these forms?
Needs to be written in C# Console App! Create a base class BankAccount. Decide what characteristics...
Needs to be written in C# Console App! Create a base class BankAccount. Decide what characteristics are common for checking and saving accounts and include these characteristics in the base class. Define derived classes for checking and savings. In your design , do not allow the banking base account to be instantiated --only the checking and saving classes. Use a Program class to test your design.
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
A, B:   Design and Implement a C# windows form application to ask the user for 10...
A, B:   Design and Implement a C# windows form application to ask the user for 10 integer numbers, sort them in ascending order and display the sorted list. Use bubble sort technique to sort the array elements and do not use any built-in sort method to sort the array elements.                                                        [02] C:    Test and evaluate your program by inputting variety of values.
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text....
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text. The application use to receive a string and display another encrypted string. The application also decrypt the encrypted string. The approach for encryption/decryption is simple one i.e. to encrypt we will add 1 to each character, so that "hello" would become "ifmmp", and to decrypt we would subtract 1 from each character.    C:   Test and evaluate application by applying different strings.      ...
Create a Java windows application to manage a list of stocks 1. Add a class Stock...
Create a Java windows application to manage a list of stocks 1. Add a class Stock with the following fields: companyName, pricePerShare, numberOfShares (currently owned) and commission (this is the percent you pay a financial company when you purchase or sell stocks. Add constructor, getters and methods: ***purchaseShares (method that takes the number of shares purchased, updates the stock and return the cost of purchasing these shares make sure to include commission. ***sellShares (method that takes the number of shares...
Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT