activy ni kennedy

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.3 kB
8
Indexable
Never
using System;

class Person
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Sex { get; set; }
    public string ContactInfo { get; set; }

    public virtual void Profile()
    {
        Console.WriteLine("Enter ID: ");
        Id = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter Name: ");
        Name = Console.ReadLine();
        Console.WriteLine("Enter Sex: ");
        Sex = Console.ReadLine();
    }
}

class Employee : Person
{
    public double GrossPay { get; set; }

    public override void Profile()
    {
        base.Profile();
        Console.WriteLine("Enter Gross Pay: ");
        GrossPay = double.Parse(Console.ReadLine());
    }
}

class Student : Person
{
    public double Grade { get; set; }
    public string Remarks { get; set; }

    public override void Profile()
    {
        base.Profile();
        Console.WriteLine("Enter Grade: ");
        Grade = double.Parse(Console.ReadLine());
    }

    public void ComputeRemarks()
    {
        if (Grade >= 70)
            Remarks = "Pass";
        else
            Remarks = "Fail";
    }
}

class BankAccount
{
    private double balance = 5000;

    public void Savings()
    {
        Console.WriteLine("Select Transaction:");
        Console.WriteLine("1. Withdraw");
        Console.WriteLine("2. Deposit");
        int choice = int.Parse(Console.ReadLine());

        switch (choice)
        {
            case 1:
                Console.WriteLine("Enter amount to withdraw: ");
                double withdrawAmount = double.Parse(Console.ReadLine());
                if (balance - withdrawAmount >= 2000)
                {
                    balance -= withdrawAmount;
                    Console.WriteLine($"Withdraw successful. Current balance: {balance}");
                }
                else
                {
                    Console.WriteLine("Withdrawal not allowed due to minimum balance constraint.");
                }
                break;

            case 2:
                Console.WriteLine("Enter amount to deposit: ");
                double depositAmount = double.Parse(Console.ReadLine());
                balance += depositAmount;
                Console.WriteLine($"Deposit successful. Current balance: {balance}");
                break;

            default:
                Console.WriteLine("Invalid choice.");
                break;
        }
    }
}

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Select role:");
        Console.WriteLine("1. Employee");
        Console.WriteLine("2. Student");
        int roleChoice = int.Parse(Console.ReadLine());

        if (roleChoice == 1)
        {
            Employee employee = new Employee();
            employee.Profile();

            BankAccount account = new BankAccount();
            account.Savings();31
        }
        else if (roleChoice == 2)
        {
            Student student = new Student();
            student.Profile();

            student.ComputeRemarks();
            Console.WriteLine($"Remarks: {student.Remarks}");
        }
        else
        {
            Console.WriteLine("Invalid choice.");
        }
    }
}