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

. Write a program to print the following outputs using for loops $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

3 Answers  


how to get the table names via c sharp and column names also?

2 Answers   Sify,


Automatically Hyperlink URLs and E-Mail Addresses in ASP.NET Pages with C#

1 Answers  


Code for Reading and writing from a file in c#?

1 Answers  


Write a program to count 3Letter, 4Letter and 5Letter words from a file and print the number of 3Letter, 4Letter and 5Letter words. Delimiter is space, tab, hifen. Also we should not consider the line in the file after we encounter # in that line.

0 Answers   Mind Tree,






how does the below eqation proceed to be solved: x*=y+z options: x=x*y+z or x=x*(y+z)

1 Answers  


How to Create Files by Using the FileInfo Class?

1 Answers  


Code for IP Address Comparison and Conversion in C#?

0 Answers  


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  


How to Link Different Data Sources Together?

0 Answers  


"c sharp" code for factorial using static variables

9 Answers  


program to check if a number is "perfect number".

1 Answers   Mind Tree, SoftSol,


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)