Professional Documents
Culture Documents
Visual Programming
Lab Journal 3
Student Name: SALMAN AYUB KHAN
Exercise 1
Create a Console application for tax calculation. Accept money as input from the user and calculate
the tax using the following table. Display the output to the user.
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace tax_calculation
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Tax Calculator " +"\n");
else
{
tax = .085 * money;
}
}
}
}
OUTPUT:
Exercise 2
Create a console application named Calculator. Display the respective menu to the user and input
two numbers from the user, on which the respective operations could be performed.
Menu
Press 1 for add
Press 2 for subtraction
Press 3 for multiplication
Press 4 for Division
Press 5: for exit
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(" Press 1 for Addition\n Press 2 for Subtraction\n Press 3 For
Multiplication\n Press 4 for Division\n Press 5 for Exit :\n");
Console.Write("Enter Your Choice :");
int choice=Convert.ToInt32(Console.ReadLine());
Console.Write("Enter first number :");
switch (choice)
{
case 1:
result = num1 + num2;
break;
case 2:
result = num1 - num2;
break;
case 3:
result = num1 * num2;
break;
case 4:
result = num1 / num2;
break;
case 5:
break;
default:
break;
}
Console.WriteLine("\nThe Result is : " + result);
Console.ReadLine();
}
}
}
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
int n = Convert.ToInt32(Console.ReadLine());
Console.Write("\n");
for (int i = n; i >= 1; i--)
{
Console.Write(" ");
Console.Write("x");
Console.Write("\n");
}
Console.ReadLine();
}
}
}
Exercise 4
Create a windows form application and repeat the same task above for it. This time the pattern
should appear on a message box.
CODE:
star+="x";
star+="\n";
MessageBox.Show(star,title,MessageBoxButtons.AbortRetryIgnore,MessageBoxIcon.Information);
}
}
}
OUTPUT:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
}
Console.ReadLine();
}
}
OUTPUT: