Thursday, March 13, 2025

Visual basic program for shopping mall

 Here is a simple Visual Basic (VB) program for a shopping mall:




Program Description:

This program allows users to:


1. View available products

2. Add products to cart

3. Remove products from cart

4. Calculate total cost

5. Make payment


Code:


Imports System.Collections.Generic


Public Class ShoppingMall


    Private products As New List(Of Product)

    Private cart As New List(Of Product)


    Public Sub New()

        ' Initialize products

        products.Add(New Product("Shirt", 20.99))

        products.Add(New Product("Pants", 30.99))

        products.Add(New Product("Shoes", 50.99))

    End Sub


    Public Sub ViewProducts()

        Console.WriteLine("Available Products:")

        For Each product In products

            Console.WriteLine($"{product.Name} - ${product.Price}")

        Next

    End Sub


    Public Sub AddToCart(productName As String)

        For Each product In products

            If product.Name = productName Then

                cart.Add(product)

                Console.WriteLine($"Added {productName} to cart.")

                Return

            End If

        Next

        Console.WriteLine("Product not found.")

    End Sub


    Public Sub RemoveFromCart(productName As String)

        For Each product In cart

            If product.Name = productName Then

                cart.Remove(product)

                Console.WriteLine($"Removed {productName} from cart.")

                Return

            End If

        Next

        Console.WriteLine("Product not found in cart.")

    End Sub


    Public Sub CalculateTotal()

        Dim total As Decimal = 0

        For Each product In cart

            total += product.Price

        Next

        Console.WriteLine($"Total: ${total}")

    End Sub


    Public Sub MakePayment()

        Console.WriteLine("Payment successful.")

        cart.Clear()

    End Sub


End Class


Public Class Product

    Public Property Name As String

    Public Property Price As Decimal


    Public Sub New(name As String, price As Decimal)

        Me.Name = name

        Me.Price = price

    End Sub

End Class


Module Program

    Sub Main()

        Dim mall As New ShoppingMall()


        While True

            Console.WriteLine("Shopping Mall Menu:")

            Console.WriteLine("1. View Products")

            Console.WriteLine("2. Add to Cart")

            Console.WriteLine("3. Remove from Cart")

            Console.WriteLine("4. Calculate Total")

            Console.WriteLine("5. Make Payment")

            Console.WriteLine("6. Exit")


            Dim choice As String = Console.ReadLine()


            Select Case choice

                Case "1"

                    mall.ViewProducts()

                Case "2"

                    Console.Write("Enter product name: ")

                    Dim productName As String = Console.ReadLine()

                    mall.AddToCart(productName)

                Case "3"

                    Console.Write("Enter product name: ")

                    Dim productName As String = Console.ReadLine()

                    mall.RemoveFromCart(productName)

                Case "4"

                    mall.CalculateTotal()

                Case "5"

                    mall.MakePayment()

                Case "6"

                    Exit While

                Case Else

                    Console.WriteLine("Invalid choice. Please try again.")

            End Select

        End While

    End Sub

End Module



How to Run:

1. Create a new VB.NET console application project in Visual Studio.

2. Copy and paste the above code into the project.

3. Run the project using F5 or the "Start" button.


Example Use Cases:

1. View available products: Choose option 1 from the menu.

2. Add product to cart: Choose option 2, enter the product name (e.g., "Shirt").

3. Remove product from cart: Choose option 3, enter the product name (e.g., "Shirt").

4. Calculate total cost: Choose option 4.

5. Make payment: Choose option 5.

Earth planet in solar system

 Earth is the third planet from the Sun in our Solar System and the only known planet to support life.


Key Facts:

1. *Diameter*: Approximately 12,742 kilometers (7,918 miles)

2. *Mass*: Approximately 5.97 x 10^24 kilograms

3. *Surface Gravity*: 9.8 meters per second squared (32 feet per second squared)

4. *Atmosphere*: Composed of 78% nitrogen, 21% oxygen, and 1% other gases

5. *Oceans*: Cover approximately 71% of the planet's surface

6. *Continents*: 7 continents: Africa, Antarctica, Asia, Australia, Europe, North America, and South America


Unique Features:

1. *Water*: Earth is the only known planet with liquid water, essential for life.

2. *Magnetic Field*: Protects the planet from harmful solar and cosmic radiation.

3. *Atmospheric Circulation*: Supports weather patterns and climate regulation.

4. *Geological Activity*: Processes like plate tectonics shape the planet's surface.


Habitability:

1. *Temperature Range*: Supports liquid water and life, with temperatures between -89°C and 57°C (-129°F and 135°F).

2. *Organic Compounds*: Presence of carbon-based molecules, building blocks of life.

3. *Energy Sources*: Receives energy from the Sun, supporting photosynthesis and life.


Earth's unique combination of features makes it an ideal haven for life to emerge and thrive.



The rotation of Earth is the movement of our planet on its axis, which is an imaginary line that runs through the North and South Poles.


Key Facts:

1. *Rotation Period*: 23 hours, 56 minutes, and 4 seconds (approximately 24 hours)

2. *Rotation Speed*: 1,674 kilometers per hour (km/h) or 1,040 miles per hour (mph) at the equator

3. *Axis Tilt*: 23.5 degrees relative to the plane of its orbit around the Sun


Effects of Rotation:

1. *Day and Night*: Rotation causes day and night cycles, with the Sun appearing to rise in the east and set in the west.

2. *Time Zones*: The rotation of Earth divides the planet into 24 time zones, each separated by one hour.

3. *Weather Patterns*: Rotation influences global wind patterns, ocean currents, and weather systems.

4. *Equatorial Bulge*: The planet's rotation causes a slight bulge at the equator due to centrifugal force.


Rotation Measurement:

1. *Sidereal Day*: The time it takes Earth to rotate once on its axis relative to the fixed stars (23 hours, 56 minutes, and 4 seconds).

2. *Solar Day*: The time it takes Earth to rotate once on its axis relative to the Sun (24 hours).


Interesting Facts:

1. Earth's rotation is slowing down due to the gravitational pull of the Moon.

2. The planet's rotation has slowed by about 1.8 milliseconds per century.

3. The length of a day on Earth has increased by about 1.78 seconds over the past 620 million years.

Featured posts

Ethiopian culture calendar language

Ethiopian culture, calendar, language  The Ethiopian language, specifically Amharic, uses a script called Ge'ez script. It consists of 3...

Popular posts