CSharp examples for Language Basics:double
Read double and do calculation
using System;/* w w w .j ava2 s . c o m*/ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { Console.Write("Enter customer price of product: "); string inputPrice = Console.ReadLine(); double customerPrice = Convert.ToDouble(inputPrice); Console.Write("Enter merchant commission (percents): "); string inputMerchantPercents = Console.ReadLine(); int merchantPercents = Convert.ToInt32(inputMerchantPercents); Console.Write("Enter distributor commission (percents): "); string inputDistributorPercents = Console.ReadLine(); int distributorPercents = Convert.ToInt32(inputDistributorPercents); // Calculations double coeficient1 = 1 - merchantPercents / 100.0; double coeficient2 = 1 - distributorPercents / 100.0; double wholesalePrice = customerPrice * coeficient1; double priceAfterCommissionSubtraction = wholesalePrice * coeficient2; double merchantIncome = customerPrice - wholesalePrice; double distributorIncome = wholesalePrice - priceAfterCommissionSubtraction; double producerIncome = priceAfterCommissionSubtraction; Console.WriteLine("Merchant: " + merchantIncome); Console.WriteLine("Distributor: " + distributorIncome); Console.WriteLine("Producer: " + producerIncome); } }