CSharp - Write program to Get Total Price

Requirements

You will calculate the total price of an order.

Hint

You need to calculate the total price including the shipping cost.

The prices and amounts of two products, as well as the shipping price, will be fixed directly in the source code.

Create constant value as follows:

const double bookPrice = 21.8;
const double dvdPrice = 9.9;
const double shipmentPrice = 25;

const defines constant value, whose values are not going to change during the program run.

Demo

using System;
class Program{/*  w  ww.j  a va2s.co m*/
    static void Main(string[] args){
        // Fixed values 
        const double bookPrice = 21.8;
        const double dvdPrice = 9.9;
        const double shipmentPrice = 25;

        // Inputs 
        Console.WriteLine("Order");

        Console.Write("Product \"Tutorial\" - enter number of pieces: ");
        string inputBookPieces = Console.ReadLine();
        int bookPieces = Convert.ToInt32(inputBookPieces);

        Console.Write("Product \"DVD\" - enter number of pieces: "); 
   
        string inputDvdPieces = Console.ReadLine();
        int dvdPieces = Convert.ToInt32(inputDvdPieces);

        // Calculations 
        double totalForBook = bookPrice * bookPieces;

        double totalForDvd = dvdPrice * dvdPieces;
        double totalForOrder = totalForBook + totalForDvd + shipmentPrice;

        // Outputs 
        Console.WriteLine("Order calculation");
        Console.WriteLine("Book: " + totalForBook);
        Console.WriteLine("Dvd: " + totalForDvd);
        Console.WriteLine("Shipment: " + shipmentPrice);
        Console.WriteLine("TOTAL: " + totalForOrder);
    }
}

Result