Working with Floating Point Types in C#
📖 Scenario: You are creating a simple program to store prices of items in a store. Different types of floating point numbers are used to understand how they behave with money values.
🎯 Goal: Build a C# program that declares variables using float, double, and decimal types, assigns values, calculates a total price, and prints the result.
📋 What You'll Learn
Create three variables named
priceFloat, priceDouble, and priceDecimal with types float, double, and decimal respectively.Assign the value 19.99 to each variable using the correct suffix for
float and decimal types.Create a variable called
quantity of type int and assign it the value 3.Calculate the total price for each type by multiplying the price by the quantity.
Print the total prices with clear labels.
💡 Why This Matters
🌍 Real World
Floating point types are used in programs that handle measurements, prices, and scientific calculations where decimals are needed.
💼 Career
Understanding float, double, and decimal types is important for software developers working with financial applications, games, simulations, and data analysis.
Progress0 / 4 steps