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...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers in the range of 1 to 100. The form should also have (1) an Add button (and input textbox) for the user to add a new number to the list, (2) a Delete button to delete the current selected integer, (3) a Sort button to sort the list, (4) a Reverse button to display the list in reverse order, and (5) Display Multiple (and...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class named PersonEntry. The PersonEntry class should have properties for a person’s name, e-mail address, and phone number. Also, create a text file that contains the names, e-mail addresses, and phone numbers for at least five people. When the application starts, it should read the data from the file and create a PersonEntry object for each person’s data. The PersonEntry objects should be added to...
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.      ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT