fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _1_6
  8. {
  9. internal class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double price, total;
  14. Console.WriteLine("******************************");
  15. Console.WriteLine(" Program Telaphone ");
  16. Console.WriteLine("******************************");
  17. // Input customer details
  18. Console.Write("phone number: ");
  19. string phoneNumber = Console.ReadLine();
  20.  
  21. Console.Write("Enter name: ");
  22. string customerName = Console.ReadLine();
  23.  
  24. Console.Write("minutes: ");
  25. int minutes = int.Parse(Console.ReadLine());
  26.  
  27. // Variable to store the total phone bill
  28. double totalCost = 0.0;
  29.  
  30. // Calculate phone bill based on conditions
  31. if (minutes <= 3)
  32. {
  33. totalCost = minutes * 3.0; // First 1-3 minutes: 3.0 per minute
  34. }
  35. else if (minutes <= 6)
  36. {
  37. totalCost = (3 * 3.0) + ((minutes - 3) * 2.0); // Next 4-6 minutes: 2.0 per minute
  38. }
  39. else if (minutes <= 11)
  40. {
  41. totalCost = (3 * 3.0) + (3 * 2.0) + ((minutes - 6) * 1.0); // Next 7-11 minutes: 1.0 per minute
  42. }
  43. else
  44. {
  45. totalCost = (3 * 3.0) + (3 * 2.0) + (5 * 1.0) + ((minutes - 11) * 0.5); // Over 11 minutes: 0.5 per minute
  46. }
  47.  
  48. // Calculate tax (7%)
  49. double tax = totalCost * 0.07;
  50.  
  51. // Calculate total amount including tax
  52. double totalWithTax = totalCost + tax;
  53.  
  54. // Display the result
  55. Console.WriteLine("\n===== Phone Bill =====");
  56. Console.WriteLine("Phone Number: " + phoneNumber);
  57. Console.WriteLine("Customer Name: " + customerName);
  58. Console.WriteLine("Minutes Used: " + minutes + " minutes");
  59. Console.WriteLine("Phone Bill: " + totalCost.ToString("F2") + " THB");
  60. Console.WriteLine("Tax (7%): " + tax.ToString("F2") + " THB");
  61. Console.WriteLine("Total Amount: " + totalWithTax.ToString("F2") + " THB");
  62.  
  63. }
  64. }
  65. }
  66.  
  67.  
Success #stdin #stdout 0.02s 25976KB
stdin
Standard input is empty
stdout
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_6
{
    internal class Program
    {
        static void Main(string[] args)
        {
            double price, total;
            Console.WriteLine("******************************");
            Console.WriteLine("       Program Telaphone      ");
            Console.WriteLine("******************************");
            // Input customer details
            Console.Write("phone number: ");
            string phoneNumber = Console.ReadLine();

            Console.Write("Enter  name: ");
            string customerName = Console.ReadLine();

            Console.Write("minutes: ");
            int minutes = int.Parse(Console.ReadLine());

            // Variable to store the total phone bill
            double totalCost = 0.0;

            // Calculate phone bill based on conditions
            if (minutes <= 3)
            {
                totalCost = minutes * 3.0; // First 1-3 minutes: 3.0 per minute
            }
            else if (minutes <= 6)
            {
                totalCost = (3 * 3.0) + ((minutes - 3) * 2.0); // Next 4-6 minutes: 2.0 per minute
            }
            else if (minutes <= 11)
            {
                totalCost = (3 * 3.0) + (3 * 2.0) + ((minutes - 6) * 1.0); // Next 7-11 minutes: 1.0 per minute
            }
            else
            {
                totalCost = (3 * 3.0) + (3 * 2.0) + (5 * 1.0) + ((minutes - 11) * 0.5); // Over 11 minutes: 0.5 per minute
            }

            // Calculate tax (7%)
            double tax = totalCost * 0.07;

            // Calculate total amount including tax
            double totalWithTax = totalCost + tax;

            // Display the result
            Console.WriteLine("\n===== Phone Bill =====");
            Console.WriteLine("Phone Number: " + phoneNumber);
            Console.WriteLine("Customer Name: " + customerName);
            Console.WriteLine("Minutes Used: " + minutes + " minutes");
            Console.WriteLine("Phone Bill: " + totalCost.ToString("F2") + " THB");
            Console.WriteLine("Tax (7%): " + tax.ToString("F2") + " THB");
            Console.WriteLine("Total Amount: " + totalWithTax.ToString("F2") + " THB");

        }
    }
}