Create a class called Accounts which has data members like
ACCOUNT no, Customer name, Account type, Transaction type
(d/w), amount, balance
D->Deposit
W->Withdrawal
If transaction type is deposit call the credit(int amount)
and update balance in this method.
If transaction type is withdraw call debit(int amt) and
update balance.
Pass the other information like Account no,name,Account
Type through constructor.
Call the show data method to display the values.



Create a class called Accounts which has data members like ACCOUNT no, Customer name, Account type..

Answer / abhinav agrawal

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Assignment3
{
internal class Accounts
{
public int ACCOUNTno;
public string CustomerName;
public string AccountType;
public string TransactionType;
public double amount;
public double balance = 1000;

public void Show()
{
Console.WriteLine("Enter Account Number:");
this.ACCOUNTno = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Customer's Name:");
this.CustomerName = Console.ReadLine();
Console.WriteLine("Enter Account Type:");
this.AccountType = Console.ReadLine();
Console.WriteLine("Enter Transaction Type (d->deposit / w->withdrawal):");
this.TransactionType = Console.ReadLine();
Console.WriteLine("Enter Amount:");
this.amount = Convert.ToDouble(Console.ReadLine());
if(TransactionType=="d")
{
TransactionType = "Deposit";
balance = balance + amount;
} else if(TransactionType=="w" && amount < balance)
{
TransactionType = "Withdrawal";
balance = balance - amount;
} else if(TransactionType=="w" && amount > balance)
{
TransactionType = "Transaction is not possible.";
}
Console.WriteLine($"

Account Number: {ACCOUNTno} Customer's Name: {CustomerName} Account Type: {AccountType}

Transaction Type: {TransactionType} Amount: {amount} Remaining Balance: {balance}

");
}
public static void Main()
{
Accounts obj = new Accounts();
obj.Show();
}
}
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Sharp Code Interview Questions

Code for IP Address Comparison and Conversion in C#?

0 Answers  


Code for Reading and writing from a file?

0 Answers   IBM, Xoriant,


how do i copy textbox contents of 1 form to another form

4 Answers   Wipro,


program to reverse the order of digits in a given number of any length.

1 Answers   Mind Tree,


Write a program to count the number of characters, number of words, number of line in file.

2 Answers   Mind Tree,






Using C# Write a program that performs the following. The user inputs a number and then enters a series of numbers from 1 to that number. Your program should determine which number (or numbers) is missing or duplicated in the series, if any. For example, if the user entered 5 as the initial number and then entered the following sequences, the results should be as shown. Input Sequence Output ---------------------- --------------- 1 2 3 4 5 Nothing bad However, if 7 were the high number, the user would see the results on the right for the following number entries: Input Sequence Output ---------------------- --------------- 1 3 2 4 5 Missing 6 Missing 7 And if 10 were the high number and the user entered the numbers shown on the left, note the list of missing and duplicate numbers: Input Sequence Output ---------------------- --------------- 1 2 4 7 4 4 5 10 8 2 6 Duplicate 2 ( 2 times) Missing 3 Duplicate 4 ( 3 times ) Missing 9 The program should check the high number that the user inputs to ensure that it does not exceed the size of any array you might be using for storage.

0 Answers  


program for straight line(y=mx+c)

0 Answers   Mind Tree,


how to change password in .net with c # with ado.net and also SQL server 2008 change password

1 Answers  


Write a program which has a function and that function should take 2 or 3 or any number of strings and it should return the largest common prefix of all those strings. If there is no common prefix it should return an empty string. for eg:- INPUT OUTPUT glo {glory,glorious,glod} gl {glad,glow} {calendar,phone} empty string

2 Answers   Mind Tree,


How to export 2 datatables of a single dataset to 2 different worksheets of a single MSExcel file ?

0 Answers   Eastcom Systems,


write a Program to copy the string using switch case.

0 Answers   Mind Tree, Wipro,


Hello Sir, Thanks for the Solution but, can you pls. Explain the coding for the Static Function & static variable from the below coding....waiting for Ans. class fact { public static void Main() { fact f=new fact(); int x=1; //Declaration of x as 1 int k=Convert.ToInt32(Console.ReadLine()); for(int i=1;i<=k;i++) { x= x *i; } System.Console.WriteLine(x); } }

0 Answers  


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)