Programming

C# – Bday year, Add, Subtraction etc.

November 29, 2015

Hi guys! long time no blog~ been very bussy this past few months due to having our thesis. So here I am, 50% done or half way on my March goal – graduation! LOL

Problem: Create a program to input your name, age, the current year, 1st number, 2nd number, that will result as the year of your birth, the sum, difference, product, quotient and remainder of the given two numbers.

Code:

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

namespace act1
{
    class Program
    {
        static void Main(string[] args)
        {
            String name;
            int age, cyear, fnumber, secnumber, sum, difference, product, quotient, remainder;
           
            System.Console.Write("Enter name: ");
            name = System.Console.ReadLine();

            System.Console.Write("Enter age: ");
            age = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("Enter current year: ");
            cyear = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("Enter first number: ");
            fnumber = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("Enter second number: ");
            secnumber = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Clear();
            System.Console.Write("Hello " + (name) + "You are born in the year " + (cyear - age));
            System.Console.ReadKey();
            System.Console.Clear();

            System.Console.WriteLine("Your first number and second number are: " + (fnumber) + "," + (secnumber));
            
            sum = fnumber + secnumber;
            difference = fnumber - secnumber;
            product = fnumber * secnumber;
            quotient = fnumber / secnumber;
            remainder = fnumber % secnumber;

            System.Console.WriteLine("Sum: "+ sum);
            System.Console.WriteLine("Difference: " + difference);
            System.Console.WriteLine("Product: " + product);
            System.Console.WriteLine("Quotient: " + quotient);
            System.Console.WriteLine("Remainder: " + remainder);

            System.Console.ReadKey();
            System.Console.Clear();

            System.Console.Write("Press any key to exit!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            System.Console.ReadKey();
            //System.Console.Clear();    

        }
    }
}

So, here are some of the screenshots to fully understand the problem. LOL

Pic1

Pic1

Pic2

Pic2

Pic3

Pic3

Pic4

Pic4

You Might Also Like...

No Comments

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.