ADVANCED WEB DEVELOPMENT PRACTICAL NO.: - 1 NAME: - Babaji Mangesh Raut. SEAT NO.: - 40/ S23078 A) Create an application to print on screen the output of adding, subtracting, multiplying and dividing two numbers entered by the user in C#. PROGRAM: - using System; namespace Operation { class Program { static void Main( string [] args) { // declare variables double a, b, w, x, y, z; //take input in fahrenheit Console .Write( "Enter first number: " ); a = Convert .ToDouble( Console .ReadLine()); Console .Write( "Enter second number: " ); b = Convert .ToDouble( Console .ReadLine()); // compute operation w = a + b; x = a - b; y = a * b; z = a / b; // display output Console .WriteLine( "Addition: " + w); Console .WriteLine( "Subtraction: " + x); Console .WriteLine( "Multiplication: " + y); Console .WriteLine( "Division: " + z); // wait for user to press any key Console .ReadKey(); } } } OUTPUT: - Enter first number: 4 Enter second number: 5 Addition: 9 Subtraction: - 1 Multiplication: 20 Division: 0.8 B) Create an application to print Floyd’s triangle till n rows in C#. PROGRAM: - using System; class MyProgram { //method for floyd triangle static void FloydTriangle( int n) { int value = 1; for ( int i = 1; i <= n; i++) { for ( int j = 1; j <= i; j++) { Console.Write( "{0} " , value); value++; } Console.WriteLine(); } } static void Main( string [] args) { FloydTriangle(7); } } OUTPUT: - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 C) Create an application to demonstrate following operations i. Generate Fibonacci series. ii. Test for prime numbers. using System; namespace FibonacciExample { class Program { static void Main( string [] args) { int num1 = 0, num2 = 1, num3, num4; Console .Write( "Enter Number Of Element : " ); num3 = Convert .ToInt32( Console .ReadLine()); Console .WriteLine( "Your Fibonacci Series Of " + num3 + " Elements is below" ); Console .Write(num1 + " " + num2 + " " ); for ( int i = 2; i < num3; i++) { num4 = num1 + num2; Conso le .Write(num4 + " " ); num1 = num2; num2 = num4; } Console .ReadKey(); } } } OUTPUT: - Enter Number Of Element : 15 Your Fibonacci Series Of 15 Elements is below 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 ADVANCED WEB DEVELOPMENT PRACTICAL NO.: - 2 NAME: - Babaji Mangesh Raut. SEAT NO.: - 40 A) Create a simple application to demonstrate the concepts boxing and unboxing. PROGRAM: - using System; class Program { static void Main( string [] args) { // Boxing: Converting a value type (int) to a reference type (object) int value = 42; // Value type object boxedValue = value; // Boxing Console .WriteLine( "Boxing:" ); Console .WriteLine( $"Value Type (int): {value} " ); Console .WriteLine( $"Boxed Value (object): {boxedValue} " ); // Unboxing: Converting a reference type (object) back to a value type (int) object anotherBoxedValue = 100; // Boxed value int unboxe dValue = ( int )anotherBoxedValue; // Unboxing Console .WriteLine( " \ n Unboxing:" ); Console .WriteLine( $"Boxed Value (object): {anotherBoxedValue} " ); Console .WriteLine( $"Unboxed Value (int): {unboxedValue} " ); // Demonstrating potential performance issue Console .WriteLine( " \ n Performance Note:" ); Console .WriteLine( "Boxing and unboxing can degrade performance. Use generics to avoid them." ); } } OUTPUT: - Boxing: Value Type (int): 42 Boxed Value (object): 42 Unboxing: Boxed Value (object): 100 Unboxed Value (int): 100 B) Create a simple application to perform addition and subtraction using delegate. using System; // This is the beginning of the Exercise7 class public class Exercise7 { // This is the main method where the program execution starts public static void Main() { // Prompting the user to enter the first number Console .Write( "Enter a number: " ); // Reading the first number entered by the user and converting it to an integer int num1 = Convert .ToInt32( Console .ReadLine()); // Prompting the user to enter the second number Console .Write( "Enter another number: " ); // Reading the second number entered by the user and converting it to a n integer int num2 = Convert .ToInt32( Console .ReadLine()); // Displaying addition of the two numbers Console .WriteLine( "{0} + {1} = {2}" , num1, num2, num1 + num2); // Displaying subtraction of the two numbers Console .WriteLine( "{0} - {1} = {2}" , num1, num2, num1 - num2); // Displaying multiplication of the two numbers Console .WriteLine( "{0} x {1} = {2}" , num1, num2, num1 * num2); // Displaying division of the two numbers Console .WriteLine( "{0} / {1} = {2}" , num1, num2, num1 / num2); // Displaying modulus (remainder) of the two numbers Console .WriteLine( "{0} mod {1} = {2}" , num1, num2, num1 % num2); } } OUTPUT: - Enter a number: 15 Enter another number: 15 15 + 15 = 30 15 - 15 = 0 15 x 15 = 225 15 / 15 = 1 15 mod 15 = 0 C) Create a simple application to demonstrate use of the concepts of interfaces. using System; namespace InterfaceExample { // Define the interface public interface IPayment { void ProcessPayment( decimal amount); } // Implement the interface in a CreditCardPayment class public class CreditCardPayment : IPayment { public void ProcessPayment( decimal amount) { Console .Writ eLine( $"Processing credit card payment of ₹ {amount} ." ); } } // Implement the interface in a PayPalPayment class public class PayPalPayment : IPayment { public void ProcessPayment( decimal amount) { Console .WriteLine( $"Processing PayPal payment of ₹ {amount} ." ); } } // Main application class Program { static void Main( string [] args) { Console .WriteLine( "Choose a payment method: 1 for Credit Card, 2 f or PayPal" ); string choice = Console .ReadLine(); IPayment paymentMethod; if (choice == "1" ) { paymentMethod = new CreditCardPayment (); } else if (choice == "2" ) { paymentMethod = new PayPalPayment (); } else { Console .WriteLine( "Invalid choice. Exiting." ); return ; } Console .WriteLine( "Enter the payment amount:" ); decimal amount = Convert .ToDecimal( Console .ReadLine()); // Process payment using the selected method paymentMethod.ProcessPayment(amount); Console .WriteLine( "Payment processed successfull y!" ); } } } OUTPUT: - Choose a payment method: 1 for Credit Card, 2 for PayPal 1 Enter the payment amount: 5000 Processing credit card payment of ?5000. Payment processed successfully! ADVANCED WEB DEVELOPMENT PRACTICAL NO.: - 3 NAME: - Babaji Mangesh Raut. SEAT NO.: - 40 A) Create a simple web page with various server controls to demonstrate setting and use of their properties. (Example : AutoPostBack) PROGRAM: - html code: - <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Server Controls Example</title> </head> <body> <form id="form1" runat="server"> <h2>ASP.NET Server Controls Example</h2> <! -- Label Control -- > <asp:Label ID="lblMessage" runat="server" Text="Select a color:"></asp:Label> <br /><br /> <! -- DropDownList Control with AutoPostBack -- > <as p:DropDownList ID="ddlColors" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlColors_SelectedIndexChanged"> <asp:ListItem Text="Red" Value="Red"></asp:ListItem> <asp:ListItem Text="Green" Value="Green"></asp:ListItem> <asp:ListItem Text="Blue" Value="Blue"></asp:ListItem> </asp:DropDownList> <br /><br /> <! -- TextBox Control -- > <asp:TextBox ID="txtName" runat="server" Placeholder="Enter your name"></asp:TextBox> <br /><br /> <! -- Button Control -- > <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" /> <br /><br /> <! -- Label to Display Output -- > <asp:Label ID="lblOutput" runat="server" Text="">< /asp:Label> </form> </body> </html> C# code: - using System; public partial class Default : System.Web.UI.Page { protected void ddlColors_SelectedIndexChanged(object sender, EventArgs e) { // Change the background color based on the selected value string selectedColor = ddlColors.SelectedValue; lblMessage.Text = "You selected: " + selectedColor; lblMessage.ForeColor = System.Drawing.Color.FromName(selectedColo r); } protected void btnSubmit_Click(object sender, EventArgs e) { // Display a message with the entered name string name = txtName.Text; lblOutput.Text = "Hello, " + name + "! Welcome to ASP.NET."; } } OUTPUT: -