Write a C# Sharp program to calculate profit and loss on a transaction

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program to calculate profit and loss on a transaction

Sample Output:

Calculate profit and loss:                                                                                    
----------------------------                                              
Input Cost Price: 1000                                                                                        
Input Selling Price: 1200                                                                                     
                                                                                                              
You can booked your profit amount : 200

الأجوبة

using System;  
public class Exercise17  
{  
    public static void Main()  
{  
    int cprice,sprice, plamt; 

           Console.Write("\n\n");
           Console.Write("Calculate profit and loss:\n");
           Console.Write("----------------------------");
           Console.Write("\n\n");
      

     Console.Write("Input Cost Price: ");  
     cprice= Convert.ToInt32(Console.ReadLine()); 
     Console.Write("Input Selling Price: ");  
     sprice= Convert.ToInt32(Console.ReadLine());  
      
    if(sprice>cprice) 
    {  
        plamt = sprice-cprice;  
        Console.Write("\nYou can booked your profit amount : {0}\n", plamt);  
    }  
    else if(cprice>sprice)  
    {  
        plamt = cprice-sprice;  
        Console.Write("\nYou got a loss of amount : {0}\n", plamt);  
    }  
    else   
    {  
        Console.Write("\nYou are running in no profit no loss condition.\n");  
    }  
}
}  
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...