Професионална програма
Loading...
deo.savchev avatar deo.savchev 1 Точки

Здравейте! Може ли някой да ми обясни как точно се решава тази задача?

static void Main(string[] args)
        {
            string type = Console.ReadLine().ToLower();
            int rows = int.Parse(Console.ReadLine());
            int columns = int.Parse(Console.ReadLine());

            int full = rows * columns;
            double income = 

            switch (type)
            {
                case "premiere":
                    income = full * 12.00;
                    break;
                case "normal":
                    income = full * 7.50;
                    break;
                case "discount":
                    income = full * 5.00;
                    break;

            }
            Console.WriteLine("leva");
        }
    }
}
 

Тагове:
0
Programming Basics
Axiomatik avatar Axiomatik 1039 Точки

Couple of problems:

1. You need to include the whole code from your Visual Studio window which also includes:

using System;

namespace Cinema
{
    class Program
    {
        static void Main(string[] args)

2. Income was not declared:

double income = 0;

3. Output message was in wrong format, use string interpolation ($"") and format with F2, in order to obtain numbers after the decimal point:

Console.WriteLine($"{income:F2}");

Code:

using System;

namespace Cinema
{
    class Program
    {
        static void Main(string[] args)
        {
            string type = Console.ReadLine().ToLower();
            int rows = int.Parse(Console.ReadLine());
            int columns = int.Parse(Console.ReadLine());

            int full = rows * columns;
            double income = 0;

            switch (type)
            {
                case "premiere":
                    income = full * 12.00;
                    break;
                case "normal":
                    income = full * 7.50;
                    break;
                case "discount":
                    income = full * 5.00;
                    break;

            }

            Console.WriteLine($"{income:F2}");
        }
    }
}

 

 

0
deo.savchev avatar deo.savchev 1 Точки

Thank you so much! 

0