using System; 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"); } } }
Standard input is empty
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"); } } }