C# Chapters

C# Program to find the cost price of one item, if the total selling price of 15 items and the total profit earned on them is input through the keyboard.

Types - C# Language Fundamentals
using System;

public class Program
{
    public static void Main()
    {
        Decimal SP, Profit, CP;
        
        Console.Write("Enter Total Selling Price and Profit : ");
        SP = Convert.ToDecimal(Console.ReadLine());
        Profit = Convert.ToDecimal(Console.ReadLine());
        
        CP = SP - Profit;
        CP = CP / 15;
        
        Console.Write("\n\nCost Price per Item is : " + CP);
    }
}

Output :
Enter Total Selling Price and Profit : 100
20

Cost Price per Item is : 6

Leave a comment
Recent Comments
No Comments